full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1Environments.ps1
Get-P1Environments.ps1
function Get-P1Environments { <# .Synopsis Get PlannerOne environments. .Description Return the PlannerOne environments informations .Parameter Tenant The PlannerOne tenant. .Parameter Product The PlannerOne product (Project or Production). .Example # Get the list of environments using a tenant Get-P1Environments -Product "Project" -Tenant "PlannerOneProd" #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [Parameter(Mandatory=$true)] [string] $Product ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $info = Get-P1Tenant $Tenant $hostName = $info.ServiceHost $servicePort = $info.WebServicePort $url = 'http://' + $hostName + ':' + $servicePort + "/Services/configuration$Product/environments" $serviceUrl = FixUrl $url $conf = (Invoke-WebRequest -Uri $serviceUrl).Content Write-Verbose "Received: $conf" $objEnv = $conf | ConvertFrom-Json $environments = @() for($i=0; ($i -le $objEnv.Length); $i++) { $environments += $objEnv[$i].Value } return $environments } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1MsiInstall.ps1
Get-P1MsiInstall.ps1
function Get-P1MsiInstall { <# .Synopsis Get all PlannerOne installation done with MSI. .Description Read Windows registry to get all PlannerOne unsintall keys. .Parameter OnlyServer Display only server installation. .Parameter InstallLocation The MSI install location to filter #> [cmdletbinding()] param( [switch] $OnlyServer, [string] $InstallLocation ) Process { $Pattern = "^PlannerOne*" if ($OnlyServer) { $Pattern = "^PlannerOne.for.Dynamics.NAV*" } if (!$InstallLocation) { $installs = gci "hklm:\software\microsoft\windows\currentversion\uninstall" | foreach { gp $_.PSPath } | select DisplayName,DisplayVersion,InstallDate,Publisher,PSChildName,InstallLocation | where { $_.DisplayName -match $Pattern } if ($installs -eq $null) { $installs = gci "hklm:\software\wow6432node\microsoft\windows\currentversion\uninstall" | foreach { gp $_.PSPath } | select DisplayName,DisplayVersion,InstallDate,Publisher,PSChildName,InstallLocation | where { $_.DisplayName -match $Pattern } } } else { $installs = gci "hklm:\software\microsoft\windows\currentversion\uninstall" | foreach { gp $_.PSPath } | select DisplayName,DisplayVersion,InstallDate,Publisher,PSChildName,InstallLocation | where { $_.DisplayName -match $Pattern -AND $_.InstallLocation -eq $InstallLocation } if ($installs -eq $null) { $installs = gci "hklm:\software\wow6432node\microsoft\windows\currentversion\uninstall" | foreach { gp $_.PSPath } | select DisplayName,DisplayVersion,InstallDate,Publisher,PSChildName,InstallLocation | where { $_.DisplayName -match $Pattern -AND $_.InstallLocation -eq $InstallLocation } } } return $installs } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1ClientPublicCertificate.ps1
Get-P1ClientPublicCertificate.ps1
function Get-P1ClientPublicCertificate { <# .Synopsis Get the public client certificate. .Description If PlannerOne is configured with certificate authentication with ERP, a certificate should have been set with Set-P1AdapterParameters. This command returns the public certificate associated to the PlannerOne client PKCS#12 (pfx) certificate. .Parameter Tenant The tenant name. .Parameter OutFile The cer file path to store public key in. .Example # Get public certificate for tenant Prod Get-P1ClientPublicCertificate -Tenant Prod #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [string] $OutFile ) Process { Write-Section "Exporting public certificate for client" if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return } $parameters = Get-P1adapterParameters $Tenant if ($parameters -eq $null) { Write-KO "No parameters to read to get certificate informations for tenant $Tenant" return } [string] $certificatePath = $parameters.ClientCertificatePath if ($certificatePath -eq "") { Write-KO "No certificate defined in configuration of tenant $Tenant" return } Write-Output "Please enter your pfx certificate's password if needed" $cert = Get-PfxCertificate $certificatePath if ($cert -eq $null) { Write-KO "Error during PFX Certificate obtention" return } New-Item $OutFile -force | Out-Null Add-Content $OutFile "-----BEGIN CERTIFICATE-----" $base64PublicCer = [System.Convert]::ToBase64String($cert.export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert), [System.Base64FormattingOptions]::InsertLineBreaks) Add-Content $OutFile $base64PublicCer Add-Content $OutFile "-----END CERTIFICATE-----" Get-Content $OutFile Write-OK "Public certificate exported to $OutFile" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Set-P1ApiKey.ps1
Set-P1ApiKey.ps1
function Set-P1ApiKey { <# .Synopsis Stores the PlannerOne API key. .Description Store locally the PlannerOne API key to access private PlannerOne feed. .Parameter ApiKey The PlannerOne ApiKey to store. #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $ApiKey ) Process { Set-ApiKey $ApiKey Write-OK "Key stored" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/New-P1WebApp.ps1
New-P1WebApp.ps1
function New-P1WebApp { <# .Synopsis Install a new PlannerOne web application. .Description Install a new PlannerOne web application in IIS. .Parameter Tenant The tenant name of this web application. .Parameter Port The port to be used by the new site. .Parameter WebAppName The name to use for web application. .Parameter LegacySite The legacy site name. Use only for migration. .Parameter ERP The ERP to use (NAV, AP, ERP) .Example # Install a PlannerOne web application for the tenant Prod on port 8042. New-P1WebApp -Tenant Prod -Port 8042 -ERP SAGE #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [int] $Port, [string] $WebAppName, [string] $LegacySite, [Parameter(Mandatory=$true)] [string] $ERP ) Process { Write-Verbose "Creating new web instance..." if ($LegacySite -eq "") { $siteName = Get-SiteNameFromTenant $Tenant } else { Write-Verbose "Site name forced to $LegacySite" $siteName = $LegacySite } $poolName = Get-PoolNameFromTenant $Tenant if (!$WebAppName) { $WebAppName = Get-WebAppNameFromTenant $Tenant } $sitePath = "$IISRootPath\$siteName" $webAppPath = "$sitePath\$WebAppName" $erpValid = Test-ERPName $ERP if (!$erpValid) { Write-Warning "$ERP is not a valid value" Write-ERPNames Write-Warning "Operation canceled" return } $packageName = Get-PackageName $P1WebPackage $ERP $webBinPath = Get-PackageFolder($packageName) Write-Verbose "Web package folder is $webBinPath" # Create Application Pool try { Get-WebAppPoolState $poolName | Out-Null Write-Verbose $poolName "Already Exists" } catch { # Assume it doesn't exist. Create it. New-WebAppPool -Name $poolName | Out-Null Write-Verbose "Pool $poolName created" Set-ItemProperty -Path IIS:\AppPools\$poolName -Name managedRuntimeVersion -Value v4.0 } # Create Folder for the website if (!(Test-Path $sitePath)) { mkdir $sitePath | Out-Null } else { Remove-Item "$sitePath\*" -recurse -Force } # Link folder to repository New-Symlink $webAppPath "$webBinPath\WebServer" $site = Get-WebSite | Where-Object { $_.Name -eq $siteName } $needSecuritySet = $false if ($null -eq $site) { if ($Port -eq 0) { $Port = $DefaultWebPort } Write-Verbose "Choose free port in IIS from $Port" $Port = Get-FreeWebPort $Port Write-Verbose "Choosen port $Port" Write-Verbose "Creating site: $siteName" New-WebSite $siteName -PhysicalPath $sitePath -Port $Port | Out-Null Write-Verbose "Security must be set on new tenant with Set-P1WebAuthentication command" $needSecuritySet = $true } else { Write-Verbose "Site $siteName already exist. Using existing site." } $webApp = Get-WebApplication -Name $WebAppName -Site $siteName if ($null -eq $webApp) { Write-Verbose "Creating web app: $WebAppName" New-WebApplication -Site $siteName -Name $WebAppName -PhysicalPath $webAppPath -ApplicationPool $poolName | Out-Null Write-Verbose "Deploying custom cultures..." & "$webAppPath\Deploy\AddSubcultures.bat" > $null } else { Write-Verbose "Web application $WebAppName already exist" } $url = "http://localhost:$Port/$WebAppName" Write-Verbose "Access PlannerOne at $url" $report = @{Port=$Port;NeedSecuritySet=$needSecuritySet} return $report } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Set-P1WebAuthentication.ps1
Set-P1WebAuthentication.ps1
function Set-P1WebAuthentication { <# .Synopsis Set the PlannerOne Web server authentication mode. .Description Set the PlannerOne web application authentication mode to Windows authentication or Formular. Change REST web service security accordingly. The formular authentication enable anonymous authentication too. .Parameter Tenant The target tenant. .Parameter Windows Set the authentication to Windows. .Parameter Formular Set the authentication to Formular. .Example # Set Windows authentication Set-P1WebAuthentication -Tenant Prod -Windows .Example # Set Formular authentication Set-P1WebAuthentication -Tenant Prod -Formular #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [switch] $Windows, [switch] $Formular ) Process { Write-Section "Setting Web Application authentication mode" if ($Windows -and $Formular) { Write-Warning "You can only choose one authentication option." return } if (!($Windows -or $Formular)) { Write-Warning "You need to choose one authentication option." return } if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } Set-WebAuthenticationInternal -Tenant $Tenant -Windows:$Windows.IsPresent -Formular:$Formular.IsPresent Register-P1WebServices $Tenant if ($Windows) { $mode = "Windows" } else { $mode = "Formular" } Write-OK "Web authentication mode set to $mode for tenant $Tenant" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Initialize-P1Environments.ps1
Initialize-P1Environments.ps1
function Initialize-P1Environments { <# .Synopsis Initialize PlannerOne environments .Description Initialize PlannerOne environments .Parameter Tenant The PlannerOne tenant. .Parameter Environments The PlannerOne environments list to initialized. .Example # Initialize all environments in $env array Initialize-P1Environments -Tenant PROD -Environments $env" #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [Parameter(Mandatory=$true)] [object] $Environments ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $info = Get-P1Tenant $Tenant $hostName = $info.ServiceHost $servicePort = $info.WebServicePort $envNumber = $Environments.Length Write-Verbose "Number of environments: $envNumber" for($i=0; ($i -le $Environments.Length); $i++) { if ($Environments[$i].EnabledInErp) { If ($Environments[$i].EnvironmentId.Kind -eq 2) { $Product = "Project" } ElseIf ($Environments[$i].EnvironmentId.Kind -eq 1) { $Product = "Production" } $envId = $Environments[$i].EnvironmentId $envName = $envId.Name $envGroup = $envId.PlanningGroupContainer $envKind = $envId.Kind $body = @{Name=$envName;PlanningGroupContainer=$envGroup;Kind=$envKind} if ($Environments[$i].EnvironmentId.PlanningGroupContainer -ne "") { Write-Section ("Initializing " + $Environments[$i].EnvironmentId.Name + $Environments[$i].EnvironmentId.PlanningGroupContainer + "...") } else { Write-Section ("Initializing " + $Environments[$i].EnvironmentId.Name + "...") } $url = 'http://' + $hostName + ':' + $servicePort + "/Services/configuration$Product/environments/init" Write-Verbose "url: $url" $serviceUrl = FixUrl $url $postBody = $body | ConvertTo-Json -Compress Write-Verbose "Body: $postBody" Invoke-WebRequest -Uri $serviceUrl -Method POST -Body $postBody -UseBasicParsing -ContentType "application/json;charset=utf-8" | Out-Null $progres = 0 Do { Start-Sleep -Milliseconds 1000 $urlProgress = 'http://' + $hostName + ':' + $servicePort + "/Services/configuration$Product/progress" $fixedProgress = FixUrl $urlProgress Write-Verbose "Querying progress: $fixedProgress" [int] $progress = (Invoke-WebRequest -Method POST -Body $postBody -Uri $urlProgress -UseBasicParsing -ContentType "application/json;charset=utf-8").Content Write-Verbose $progress if ($progress -ge 0) { Write-Progress -activity "Initializing in Progress" -status "$progress% complete" -percentcomplete $progress } } While ($progress -ge 0 -and $progress -le 99) } } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Uninstall-P1Msi.ps1
Uninstall-P1Msi.ps1
function Uninstall-P1Msi { <# .Synopsis Uninstall a legacy MSI installation of PlannerOne. .Description Read Windows registry base for uninstall key and uninstall from PlannerOne from MSI. Call Get-P1MsiInstall and use PSChildName key to uninstall with this command. .Parameter UninstallKey The MSI uninstall key. #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $UninstallKey ) Process { # Out-Null is here for synchronous exe call . msiexec /x $UninstallKey /quiet | Out-Null } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Update-P1ToggleEnvironmentsAutoPublish.ps1
Update-P1ToggleEnvironmentsAutoPublish.ps1
function Update-P1ToggleEnvironmentsAutoPublish { <# .Synopsis Toggle auto publish on PlannerOne environments .Description Toggle auto publish on PlannerOne environments. The environment list must be up to date. This command works only with PlannerOne project environments. .Parameter Tenant The PlannerOne tenant. .Parameter Environments The PlannerOne environments list to toggle auto publish value. .Example # Toggle auto publish value on all environments in $env array Update-P1ToggleEnvironmentsAutoPublish -Tenant PROD -Environments $env #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [Parameter(Mandatory=$true)] [object] $Environments ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $info = Get-P1Tenant $Tenant $hostName = $info.ServiceHost $servicePort = $info.WebServicePort $envNumber = $Environments.Length Write-Verbose "Number of environments: $envNumber" for($i=0; ($i -le $Environments.Length); $i++) { if ($Environments[$i].EnabledInErp -and $Environments[$i].IsInPlannerOne) { If ($Environments[$i].EnvironmentId.Kind -eq 2) { $Product = "Project" } ElseIf ($Environments[$i].EnvironmentId.Kind -eq 1) { $Product = "Production" } Write-Section ("Toogle auto publish for environment:") Write-Section (" Compagny name: " + $Environments[$i].EnvironmentId.Name) Write-Section (" PGC: " + $Environments[$i].EnvironmentId.PlanningGroupContainer) $url = 'http://' + $hostName + ':' + $servicePort + "/Services/configuration$Product/environments/toggleAutoPublish" Write-Verbose "url: $url" $serviceUrl = FixUrl $url $postBody = $Environments[$i] | ConvertTo-Json Invoke-WebRequest -Uri $serviceUrl -Method POST -Body $postBody -UseBasicParsing -ContentType "application/json;charset=utf-8" | Out-Null } } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Remove-P1WebApp.ps1
Remove-P1WebApp.ps1
function Remove-P1WebApp { <# .Synopsis Uninstall a existing PlannerOne web application. .Description Uninstall a existing PlannerOne web application with the given parameters. .Parameter Tenant The tenant name of this web application. .Example # Uninstall a PlannerOne web application for the tenant Prod. Remove-P1WebApp -Tenant Prod #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { Write-Section "Removing web instance..." $siteName = Get-SiteNameFromTenant $Tenant $poolName = Get-PoolNameFromTenant $Tenant $TenantInfo = Get-TenantInfo $Tenant if ($TenantInfo -ne $null) { $WebAppName = $TenantInfo.WebApplicationName Write-Verbose "Web application name read from tenant info is $WebAppName" } if (!$WebAppName) { Write-Verbose "No tenant info for web application name. Created one from convention" $WebAppName = Get-WebAppNameFromTenant $Tenant } $sitePath = "$IISRootPath\$siteName" $webAppPath = "$sitePath\$WebAppName" # Remove WebApp Write-Verbose "Removing web app: $WebAppName" Remove-WebApplication -Name $WebAppName -Site $siteName # Remove Site Write-Verbose "Removing site: $siteName" Remove-WebSite -Name $siteName | Out-Null # Remove Pool Write-Verbose "Removing pool: $poolName" Stop-WebAppPool -Name $poolName Write-Output "Waiting 5 seconds for service to really stop." Start-Sleep -seconds 5 Remove-WebAppPool -Name $poolName # Remove WebApp folder Write-Verbose "Removing folder: $webAppPath" Remove-Symlink $webAppPath # Remove Site folder Write-Verbose "Removing folder: $sitePath" Remove-Item $sitePath -recurse -Force Write-OK "Web instance removed" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Remove-P1Environments.ps1
Remove-P1Environments.ps1
function Remove-P1Environments { <# .Synopsis Remove PlannerOne environments .Description Remove PlannerOne environments .Parameter Tenant The PlannerOne tenant. .Parameter Environments The PlannerOne environments list to initialized. .Example # Remove all environments in $env array Remove-P1Environments -Tenant PROD -Environments $env #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [Parameter(Mandatory=$true)] [object] $Environments ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $info = Get-P1Tenant $Tenant $hostName = $info.ServiceHost $servicePort = $info.WebServicePort $envNumber = $Environments.Length Write-Verbose "Number of environments: $envNumber" for($i=0; ($i -le $Environments.Length); $i++) { if ($Environments[$i].EnabledInErp -and $Environments[$i].IsInPlannerOne) { If ($Environments[$i].EnvironmentId.Kind -eq 2) { $Product = "Project" } ElseIf ($Environments[$i].EnvironmentId.Kind -eq 1) { $Product = "Production" } Write-Section ("Delete environment:") Write-Section (" Compagny name: " + $Environments[$i].EnvironmentId.Name) Write-Section (" PGC: " + $Environments[$i].EnvironmentId.PlanningGroupContainer) $url = 'http://' + $hostName + ':' + $servicePort + "/Services/configuration$Product/environments" Write-Verbose "url: $url" $serviceUrl = FixUrl $url $postBody = $Environments[$i] | ConvertTo-Json Invoke-WebRequest -Uri $serviceUrl -Method DELETE -Body $postBody -UseBasicParsing -ContentType "application/json;charset=utf-8" | Out-Null } } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Watch-P1WebModel.ps1
Watch-P1WebModel.ps1
function Watch-P1WebModel { <# .Synopsis Watch the model versions on PlannerOne web. .Description Display for each session in PlannerOne Web application the model versions. .Parameter Tenant The tenant to use to retrieve connection informations. .Parameter HostName The hostname to query (default localhost) .Parameter ServicePort The hostname port of PlannerOne web Service (default 80) .Parameter WebAppName The web application name of PlannerOne (default PlannerOne) .Example Watch-P1WebModel -ServicePort 8073 #> [cmdletbinding()] param( [string] $Tenant, [string] $HostName, [int] $ServicePort, [string] $WebAppName ) Process { if ($Tenant -ne "") { $info = Get-TenantInfo $Tenant if ($info -eq $null) { Write-Warning "No information registered for tenant $Tenant" return } $HostName = $info.WebHost $ServicePort = $info.SitePort $WebAppName = $info.WebApplicationName } else { $Tenant = "NA" } if ($HostName -eq "") { $HostName = "localhost" } if ($ServicePort -eq 0) { $ServicePort = 80 } if ($WebAppName -eq "") { $WebAppName = "PlannerOne" } $url = 'http://' + $HostName + ':' + $ServicePort + '/' + $WebAppName + '/Api/CacheInfo.svc/versions' $serviceUrl = FixUrl $url $auto = $true $clean = $true $continue = $true while($continue) { clear echo "Tenant: $Tenant - Host: $HostName - Port: $ServicePort - WebApp: $WebAppName" $lastRefresh = Get-Date echo "$lastRefresh - Version format: Planning | Static | Dynamic" $stateJson = (wget $serviceUrl -UseDefaultCredentials).Content $state = $stateJson | ConvertFrom-Json Write-Verbose "state: $state" if ($state -ne $null) { $web = "WebApplication: " + $state.Name # echo $web foreach ($session in $state.Sessions) { if ($clean -eq $false -or $session.Environments -ne $null) { $sess = "Session: " + $session.Id echo $sess foreach ($env in $session.Environments) { $environment = "|_Environment: " + $env.Key echo $environment $vw = Get-PlanningVersionWeb $env.Working echo "| |_Working:`t$vw" $vp = Get-PlanningVersionWeb $env.Published echo "| |_Published:`t$vp" foreach ($tab in $env.Tabs) { $t = $tab.Key $v = "View: " + $tab.Version.View + " | Last: " + $tab.Version.Last echo "| |_$t : $v" } echo "|" } echo "" } } } echo "ESCAPE: Quit | R: Refresh | A: Auto-Refresh (5s): $auto | C: Clean empty sessions: $clean" $counter = 0 if ($auto) { while(![console]::KeyAvailable -and ($counter++ -lt 10)) { [Threading.Thread]::Sleep( 500 ) } } if ([console]::KeyAvailable -or !$auto) { $x = [System.Console]::ReadKey() switch ($x.key) { # http://msdn.microsoft.com/en-us/library/system.consolekey(v=vs.110).aspx Escape { $continue = $false } R { } A { $auto = !$auto } C { $clean = !$clean } } } } Write-Output "Watch end" # Write-Host must be call for ReadKey to not corrupt the console Write-Host } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Test-P1Prerequisites.ps1
Test-P1Prerequisites.ps1
function Test-P1Prerequisites { <# .Synopsis Test if prerequisites of PlannerOne are installed on the machine. .Description Look for a list a features that must be installed. Use Install parameter to force installation of missing features. .Parameter Install Force installation of missing features. .Parameter AppServerOnly Install only PlannerOne application server prerequisites .Example # Test prerequisites and install missing features. Test-P1Prerequisites -Install #> [cmdletbinding()] param ( [switch] $Install = $false, [switch] $AppServerOnly = $false ) Process { if (Get-Module -ListAvailable -Name 'ServerManager') { Import-Module 'ServerManager' if ($AppServerOnly) { $featureNames = ('NET-Framework-45-Core') } else { $featureNames = ('Web-Server', 'Web-Mgmt-Console', 'Web-Windows-Auth', 'NET-Framework-45-Core', 'Web-Asp-Net45', 'Web-Net-Ext45', 'Web-ISAPI-Filter', 'Web-ISAPI-Ext', 'NET-WCF-HTTP-Activation45', 'NET-Framework-45-ASPNET') } Write-Verbose "Checking PlannerOne's prerequisites..." $features = Get-WindowsFeature $featureNames $missingFeatures = ($features | Where-Object InstallState -ne Installed) if ($missingFeatures.Count -eq 0) { Write-Verbose 'No missing features! Ready for PlannerOne!' } else { if ($Install) { Write-Verbose 'Installing missing features' Add-WindowsFeature $missingFeatures | Out-Null $features = Get-WindowsFeature $featureNames } else { Write-Warning 'Something is missing. Run the command again with -Install to fullfill prerequisites.' Write-Warning 'Run with -AppServerOnly switch to test only PlannerOne application server prerequisites.' } } } elseif ((Get-Module -ListAvailable -Name 'DISM') -Or (Test-Path $DISMModulePath)) { if ($AppServerOnly) { Write-Warning "AppServerOnly option is not available in DISM mode." return } if (Test-Path $DISMModulePath) { Write-Verbose "Using $DISMModulePath to load DISM module" Import-Module $DISMModulePath $env:path = $DISMModulePath } else { Import-Module 'DISM' } $featureNames = ('IIS-WebServer', 'IIS-ManagementConsole', 'IIS-WindowsAuthentication', 'IIS-ASPNET45', 'IIS-NetFxExtensibility45', 'IIS-ISAPIFilter', 'IIS-ISAPIExtensions', 'WCF-HTTP-Activation45', 'NetFx4Extended-ASPNET45') Write-Verbose "Checking PlannerOne's prerequisites..." $features = @() foreach ($featureName in $featureNames) { $tempFeature = Get-WindowsOptionalFeature -Online -FeatureName $featureName if ($null -ne $tempFeature) { $features += $tempFeature } else { Write-Warning "Feature $featureName not found!" } } $missingFeatures = ($features | Where-Object State -ne Enabled) if ($missingFeatures.Count -eq 0) { Write-Verbose 'No missing features! Ready for PlannerOne!' } else { if ($Install) { Write-Verbose 'Installing missing features' $features = @() foreach ($missingFeature in $missingFeatures) { Enable-WindowsOptionalFeature -Online -FeatureName $missingFeature.FeatureName -All | Out-Null $features += Get-WindowsOptionalFeature -Online -FeatureName $missingFeature.FeatureName } } else { Write-Warning 'Something is missing. Run the command again with -Install to fullfill prerequisites.' } } } else { Write-Warning 'Your OS doesn''t allow automatic installation of PlannerOne prerequisites.' Write-Warning 'If your are using Windows 7 or 8, try to install Windows ADK (https://technet.microsoft.com/en-us/library/hh825494.aspx) and retry.' } return $features } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1Packages.ps1
Get-P1Packages.ps1
function Get-P1Packages { <# .Synopsis List all available packages from PlannerOne NuGet server. .Description Connect to remote repository and list the latest release. #> [cmdletbinding()] param( ) Process { Write-Verbose "Reading PlannerOne package from repository..." $feedUrl = Get-FeedUrl if ($feedUrl -eq "") { return } if (Get-Command Find-Package -errorAction SilentlyContinue) { Write-Verbose "Find-Package exists" $packages = Find-Package -Source $feedUrl } else { Write-Verbose "Find-Package doesn't exist, using NuGet" $packages = NuGet list -Source $feedUrl } return $packages } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Start-P1.ps1
Start-P1.ps1
function Start-P1 { <# .Synopsis Start PlannerOne product. .Description Start PlannerOne product with web client. .Parameter Tenant The target tenant. .Example # Start PlannerOne for tenant named Prod. Start-P1 -Tenant Prod #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $info = Get-P1Tenant $Tenant $host = $info.WebHost $port = $info.SitePort $app = $info.WebApplicationName $url = "http://" + $host + ":" + $port + "/" + $app Write-Verbose "Opening $url" [Diagnostics.Process]::Start($url) | Out-Null } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Unregister-P1Tenant.ps1
Unregister-P1Tenant.ps1
function Unregister-P1Tenant { <# .Synopsis DEV TOOL - Use Remove-P1Tenant cmdlet if you want to uninstall an existing PlannerOne tenant. Unregister an existing PlannerOne tenant. .Description DEV TOOL. Unregister an existing PlannerOne tenant with the given parameters. This command does not uninstall the product. .Parameter Tenant The tenant name. .Parameter RemoveData Remove all the data stored for this tenant. .Example # Uninstall a PlannerOne tenant named P1Prod. Unregister-P1Tenant -Tenant NavDev #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [switch] $RemoveData ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." return } Write-Section "Unregistering tenant..." Remove-Tenant -Tenant $Tenant -RemoveData:$RemoveData.IsPresent Write-OK "Tenant '$Tenant' unregistered" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Remove-P1Tenant.ps1
Remove-P1Tenant.ps1
function Remove-P1Tenant { <# .Synopsis Uninstall an existing PlannerOne tenant (service + web app). .Description Uninstall an existing PlannerOne tenant with the given parameters. .Parameter Tenant The tenant name. .Parameter RemoveData Remove all the data stored for this tenant. .Parameter WebAppName The web application name if customized. .Example # Uninstall a PlannerOne tenant named P1Prod. Remove-P1Tenant -Tenant P1Prod #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [switch] $RemoveData ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." return } Write-Section "Removing tenant..." Remove-P1ServerInstance -Tenant $Tenant Remove-P1WebApp -Tenant $Tenant Remove-Tenant -Tenant $Tenant -RemoveData:$RemoveData.IsPresent Write-OK "Tenant '$Tenant' removed" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Restart-P1Tenant.ps1
Restart-P1Tenant.ps1
function Restart-P1Tenant { <# .Synopsis Restart a PlannerOne tenant .Description Restart a PlannerOne tenant by restarting web application and service. .Parameter Tenant The target tenant. #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { Write-Section "Restaring tenant $Tenant" if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $info = Get-P1Tenant $Tenant $webApp = Get-P1WebApplication $Tenant if ($webApp -eq $null) { Write-KO "Cannot find the web application for tenant $Tenant" return } Restart-Tenant $webApp $info Write-OK "Tenant $Tenant restarted" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1ApiKey.ps1
Get-P1ApiKey.ps1
function Get-P1ApiKey { <# .Synopsis Gets the stored the PlannerOne API key. .Description Read the locally stored PlannerOne API key to access private PlannerOne feed. #> [cmdletbinding()] param( ) Process { return Get-ApiKey } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1SampleScripts.ps1
Get-P1SampleScripts.ps1
function Get-P1SampleScripts { <# .Synopsis Get sample scripts from PlannerOne Web Site. .Description The sample scripts could be adapted and customized to your need. It should work as-is if you're using Demo envrionment. .Example The ERP associated to sample scripts (NAV or SAGE). .Example # Get the sample scripts. Get-P1SampleScripts #> [cmdletbinding()] param( [string] $ERP ) Process { if ($ERP -eq "") { $ERP = "NAV" } if ($ERP -ne "NAV" -and $ERP -ne "SAGE") { Write-Warning "Invalid ERP name. Please enter a valid value: NAV, SAGE" return } $LocalSamplesFolder = "$HOME\Documents\P1Samples" if (!(Test-Path $LocalSamplesFolder)) { New-Item -Path "$LocalSamplesFolder" -ItemType Directory | Out-Null Write-Verbose "Folder $LocalSamplesFolder has been created." } $url = $SamplesURL.Replace("[ERP]", $ERP) Write-Verbose "Getting file list from URL $url/list.php." $FileList = (Invoke-WebRequest -Uri "$url/list.php").Content | ConvertFrom-Json $FileCount = $FileList.Count Write-Verbose "File list contains $FileCount files(s)." foreach ($File in $FileList) { Write-Verbose "Downloading file $url/$File" Invoke-WebRequest -Uri "$url/$File" -OutFile "$LocalSamplesFolder\$File" -Headers @{"Cache-Control"="no-cache";"User-Agent"="Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko"} } Write-Output "$FileCount sample scripts has been copied to folder $LocalSamplesFolder." Write-Output "Run ise to edit, customize and run the script the most adapted to your scenario." } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1Log.ps1
Get-P1Log.ps1
function Get-P1Log { <# .Synopsis Get the logs for a tenant .Description Return the list of logs of their content. .Parameter Tenant The tenant name. .Parameter LogType logService, logManager or logWeb .parameter LogName The log name to display .parameter Wait Wait modification on log to display .Example # Get the list of logs Get-P1Log -Tenant Prod .Example # Get a log for logService and follow it Get-P1Log -Tenant Prod -LogType logService -LogName PlannerOneApplication.log -Wait #> [cmdletbinding()] param( [string] $Tenant, [string] $LogType, [string] $LogName, [switch] $Wait ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return } $path = Get-LogPathFromTenant $Tenant if ($LogType -ne "") { $path = $path + $LogType if (!(Test-Path $path)) { Write-KO "The log type $LogType does not exist." return } } if ($LogName -eq "") { $logs = Get-ChildItem -Recurse $path -Filter *.log* $logInfos = @() foreach ($log in $logs) { $logInfo = new-object psobject -property @{ "LogType" = $log.Directory.Name; "LogName" = $log.Name; } $logInfos += $logInfo } Write-Output $logInfos | Format-Table } else { $path = $path + "\" + $LogName if (!(Test-Path $path)) { Write-KO "Log $LogType $LogName does not exist" return } else { Get-Content $path -Wait:$Wait.IsPresent } } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Register-P1Tenant.ps1
Register-P1Tenant.ps1
function Register-P1Tenant { <# .Synopsis DEV TOOL - Use New-P1Tenant cmdlet if you want to install a new PlannerOne tenant. Register a new PlannerOne tenant. .Description DEV TOOL. Register a new PlannerOne tenant with the given parameters. Does not deploy the product. Every name are set by convention from tenant name if they are not overloaded. Keep convention name if possible for easier maintenance. Web service port and remoting port are declined from web port. Use BinPath to force main binary path (NavAdapterApplication.exe, PlannerOneService.exe, PlannerOne.exe...) .Parameter Tenant The tenant name. .Parameter BinPath The binary path of main PlannerOne service / debug process. .Parameter WebServicePort The port to be used by AppServer for REST API. .Parameter RemotingPort The port to be used by AppServer for Remoting API. .Parameter WebPort The customized port to be used by WebServer site. .Parameter WebAppName The customized name to use for web application. .Parameter ERP The ERP to use (NAV, AP, SAGE). .Example # Install a PlannerOne tenant named P1Prod. Register-P1Tenant -Tenant NavDev -WebPort 8142 -ERP NAV -BinPath "C:\dotNet\Projects\PlannerOne\branches\dev\NavAdapter\bin\Debug" #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [string] $BinPath, [int] $RemotingPort, [int] $WebServicePort, [int] $WebPort, [string] $WebAppName, [Parameter(Mandatory=$true)] [string] $ERP ) Process { if (Test-Tenant $Tenant) { Write-Warning "Tenant $Tenant already exist. Creation canceled." Write-Warning "Type Get-Help New-P1Tenant for more information." return } if ($ERP -eq "") { Write-Warning "ERP is not defined." Write-Warning "Please select call New-P1Tenant again with -ERP flag (NAV, AP, SAGE)" return } $erpValid = Test-ERPName $ERP if (!$erpValid) { Write-Warning "$ERP is not a valid value" Write-ERPNames Write-Warning "Operation canceled" return } Write-Section "Registering tenant $Tenant..." if ($WebPort -eq 0) { $WebPort = $DefaultWebPort } if (!$WebAppName) { $WebAppName = Get-WebAppNameFromTenant $Tenant Write-Verbose "Web application name: $WebAppName" } if ($WebPort -eq 0) { $WebPort = 8042 Write-Verbose "Web port set to default: $WebPort" } if ($WebServicePort -eq 0) { $WebServicePort = $WebPort + 1 Write-Verbose "Web service port: $WebServicePort" } if ($RemotingPort -eq 0) { Write-Verbose "Remoting port: $RemotingPort" $RemotingPort = $WebPort + 2 } $adapter = $ERPToAdapter.Get_Item($ERP) Write-Verbose "Adapter associated to ERP is $adapter" Write-Section "Registrating tenant..." Register-Tenant -Tenant $Tenant -RemotingPort $RemotingPort -WebServicePort $WebServicePort -WebAppName $WebAppName -SitePort $WebPort -Adapter $adapter -BinPath $BinPath Restore-P1WebSecurity -Tenant $Tenant Write-OK "Registration done" Get-P1tenant $Tenant } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Watch-P1Commands.ps1
Watch-P1Commands.ps1
function Watch-P1Commands { <# .Synopsis Watch the commands on PlannerOne server. .Description Display for one environment loaded in PlannerOne the current command, queued commands and executed commands. .Parameter Tenant The tenant to use to retrieve connection informations. .Parameter HostName The hostname to query (default localhost) .Parameter ServicePort The hostname port of REST Service (default 80) .Parameter Product The product to query (PS or RP - Default PS) .Parameter NameFilter Filter for the environment name. .Example Watch-P1ServerModel -ServicePort 8073 #> [cmdletbinding()] param( [string] $Tenant, [string] $HostName, [int] $ServicePort, [string] $Product, [string] $NameFilter ) Process { if ($Tenant -ne "") { $info = Get-TenantInfo $Tenant if ($info -eq $null) { Write-Warning "No information registered for tenant $Tenant" return } $HostName = $info.ServiceHost $ServicePort = $info.WebServicePort } else { $Tenant = "NA" } if ($HostName -eq "") { $HostName = "localhost" } if ($ServicePort -eq 0) { $ServicePort = 80 } [string] $message = "" $state = 0 $auto = $true $continue = $true while($continue) { clear echo "Tenant: $Tenant - Host: $HostName - Port: $ServicePort" Get-Date if ($state -eq 0) { if ($Product -ne "RP") { $Product = "PS" $service = "commandproduction" } else { $service = "commandproject" } $escapedService = EscapeQueryData $service $url = 'http://' + $HostName + ':' + $ServicePort + "/Services/$escapedService/" $serviceUrl = FixUrl $url Write-Verbose $serviceUrl echo "Product: $Product - Filter: $NameFilter" if ($message -ne "") { echo $message $message = "" } $ids = (wget $serviceUrl).Content Write-Verbose $ids $idsObj = $ids | ConvertFrom-Json $filteredArray = @() $displayArray = @() if ($idsObj.Length -eq 0) { Write-Output "NO COMMAND EXECUTER FOR $Product" } else { [int] $i = 1 foreach ($env in $idsObj) { $envName = $env.Name $peak = $true if ($NameFilter -ne "") { if (!($envName.Contains($NameFilter))) { $peak = $false } } if ($peak) { $displayObj = New-Object System.Object $displayObj | Add-Member -type NoteProperty -name No -value $i $displayObj | Add-Member -type NoteProperty -name Name -value $envName $displayObj | Add-Member -type NoteProperty -name Group -value $env.PlanningGroupContainer $displayArray += $displayObj $filteredArray += $env } $i++ } $displayArray | Format-Table } echo "ESCAPE: Quit | R: Refresh | 1-9: Select environment | S: PS/RP switch" $x = [System.Console]::ReadKey() [int] $select = -1 switch ($x.key) { # http://msdn.microsoft.com/en-us/library/system.consolekey(v=vs.110).aspx Escape { $continue = $false } R {} S { if ($Product -eq "PS") { $Product = "RP" } else { $Product = "PS" } } D1 { $select = 0 } D2 { $select = 1 } D3 { $select = 2 } D4 { $select = 3 } D5 { $select = 4 } D6 { $select = 5 } D7 { $select = 6 } D8 { $select = 7 } D9 { $select = 8 } NumPad1 { $select = 0 } NumPad2 { $select = 1 } NumPad3 { $select = 2 } NumPad4 { $select = 3 } NumPad5 { $select = 4 } NumPad6 { $select = 5 } NumPad7 { $select = 6 } NumPad8 { $select = 7 } NumPad9 { $select = 8 } } if ($select -ne -1) { if ($select -gt $filteredArray.Length) { $message = "Selected environment does not exist" } else { $selectedEnv = $filteredArray[$select] $state = 1 clear } } } else { if ($state -eq 1 -and $continue) { $escapedService = EscapeQueryData $service $escapedName = EscapeQueryData $selectedEnv.Name $escapedGroup = EscapeQueryData $selectedEnv.PlanningGroupContainer $url = 'http://' + $HostName + ':' + $ServicePort + "/Services/" + $escapedService + "/" + $escapedName + '/' + $escapedGroup $serviceUrl = FixUrl $url Write-Verbose $serviceUrl $headLine = "Product: $Product - Environment: " + $selectedEnv.Name + " - " + $selectedEnv.PlanningGroupContainer echo $headLine $commands = (wget $serviceUrl).Content Write-Verbose $commands $commandsObj = $commands | ConvertFrom-Json $commandsObj | Format-Table echo "ESCAPE: Quit | R: Refresh | L: Got back to list | A: Auto-Refresh (5s): $auto" $counter = 0 if ($auto) { while(![console]::KeyAvailable -and ($counter++ -lt 10)) { [Threading.Thread]::Sleep( 500 ) } } if ([console]::KeyAvailable -or !$auto) { $x = [System.Console]::ReadKey() switch ($x.key) { # http://msdn.microsoft.com/en-us/library/system.consolekey(v=vs.110).aspx Escape { $continue = $false } R {} L { $selectedEnv = $null $state = 0 } A { $auto = !$auto } } } } } } Write-Output "Watch end" # Write-Host must be call for ReadKey to not corrupt the console Write-Host } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Update-P1LegacyRole.ps1
Update-P1LegacyRole.ps1
function Update-P1LegacyRole { <# .Synopsis Migrate an installed legacy role to new tenant and WMF system. .Description Search for existing Role and existing MSI installation to migrate to new tenant and WMF install system. .Parameter Role The role name to migrate. .Parameter ERP The ERP to use. .Parameter LegacySite The site name to use. Only use if auto-detection does not work. .Parameter NoUninstall Skip legacy product uninstall step. #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Role, [Parameter(Mandatory=$true)] [string] $ERP, [string] $LegacySite, [switch] $NoUninstall ) Process { # Read role file for $Role and capture informations $roleInfo = Get-P1LegacyRole $Role if (!$roleInfo) { Write-Warning "Role $Role does not exist" return } $erpValid = Test-ERPName $ERP if (!$erpValid) { Write-Warning "$ERP is not a valid value" Write-ERPNames Write-Warning "Migration canceled" return } Write-Section "Migrating legacy Role of PlannerOne..." $Tenant = $Role Write-Verbose "ERP is $ERP" if (Test-Tenant $Tenant) { Write-Warning "Tenant $Tenant already exist. Migration canceled." return } # Test PlannerOne Manager is not running $rolePath = $roleInfo.Path $PM = Get-Process | Where-Object { $_.Path -eq "$rolePath\PlannerOneManager.exe" } if ($null -ne $PM) { Write-Warning "Please close PlannerOne Manager for the role $Role before migration." Write-Warning "Migration canceled" return } # Test Database access $dbConfig = Test-DBConfig $Role if ($dbConfig -eq $false) { Write-Warning "Migration canceled." return } $dbConnect = Test-DBConnection $Role if ($dbConnect -eq $false) { Write-Warning "Migration canceled." return } # Test packages $packageName = Get-PackageName $P1SrvPackage $ERP $package = Get-Package $packageName if ($package -eq $null) { Write-Warning "Package $packageName does not exist." Write-Warning "Call Install-P1Package with missing packages." return } $packageName = Get-PackageName $P1WebPackage $ERP $package = Get-Package $packageName if ($package -eq $null) { Write-Warning "Package $packageName does not exist." Write-Warning "Call Install-P1Package with missing packages." return } # Test prerequisites $iisCommand = Get-Command New-WebAppPool if ($iisCommand -eq $null) { Write-Warning "Command New-WebAppPool does not exist." Write-Warning "Please run Test-P1Prerequisites." return } # Search role site Write-Section "Getting legacy web site information" $WebAppName = $roleInfo.WebApplicationName if ($LegacySite -eq "") { Write-Verbose "Searching for site containing web application $WebAppName" $installedWebApp = get-webapplication $WebAppName if ($installedWebApp -eq $null) { Write-Warning "Cannot find a web application named $WebAppName" Write-Warning "Relaunch with -LegacySite parameter" return } $searchSiteName = $installedWebApp.GetParentElement()["Name"] $webSite = Get-WebSite $searchSiteName if ($webSite.Count -gt 1) { Write-Warning "Cannot determine which web site to use: Multiple web application with name $WebAppName" Write-Warning "Relaunch with -LegacySite parameter" return } $legacySiteName = $webSite.Name } else { $legacySiteName = $LegacySite } $site = Get-WebSite $legacySiteName if ($site -eq $null) { Write-Warning "Site $legacySiteName does not exist." Write-Warning "Update canceled" return } # Using first binding port as default port is site is uninstalled by MSI and must be recreated $portStr = $site.Bindings.Collection[0].bindingInformation $legacyPort = Get-BindingPort $portStr Write-Verbose "Legacy first binding port is $legacyPort" Write-OK "Legacy Web site found" # Search for MSI uninstall from path and uninstall if ($NoUninstall) { Write-OK "Skipping legacy product uninstall step." } else { Write-Section "Uninstalling existing legacy product (can take several minutes...)" $rolePath = $roleInfo.Path $msiLocation = (get-item $rolePath).parent.FullName + "\" Write-Verbose "Searching for PlannerOne uninstall information for location $msiLocation" $uninstallInfo = Get-P1MsiInstall -OnlyServer -InstallLocation $msiLocation $componentId = $uninstallInfo.PSChildName if ($componentId -eq $null) { Write-Warning "Cannot find component Id for PlannerOne installed in $msiLocation" Write-Warning "Rerun with -NoUninstall if you want to by pass uninstallation step" Write-Warning "Update canceled" return } Write-Verbose "Component ID to remove is $componentId" Write-Verbose "Uninstalling product" Uninstall-P1Msi -UninstallKey $componentId } # Remove service and web app in case of uninstall error Write-Verbose "Removing legacy windows service" Remove-Service $roleInfo.WindowsServiceName | Out-Null Write-Verbose "Removing legacy web app" Remove-WebApplication -Name $WebAppName -Site $legacySiteName -ErrorAction "SilentlyContinue" | Out-Null Write-OK "Legacy PlannerOne uninstalled" # Install Web app $webReport = New-P1WebApp -Tenant $Tenant -WebAppName $WebAppName -LegacySite $legacySiteName -Port $legacyPort -ERP $ERP $SitePort = $webReport.Port Write-OK "Web created on port $SitePort" # Migrate role to tenant (register tenant, app server, web app) Write-Section "Migrating Role to Tenant" $RemotingPort = $roleInfo.RemotingPort $WebServicePort = $roleInfo.WebServicePort $adapter = $ERPToAdapter.Get_Item($ERP) Write-Verbose "Adapter associated to ERP is $adapter" Register-Tenant -Tenant $Tenant -RemotingPort $RemotingPort -WebServicePort $WebServicePort -WebAppName $WebAppName -SitePort $SitePort -Adapter $adapter $migrationReport = @{ MigrationDone = $true; MigrationSuccess = $true; MigrationError = "" } $json = $migrationReport | ConvertTo-Json $storeBasePath = Get-GlobalReportPath $storePath = $storeBasePath + $Tenant + ".json" if (!(Test-Path $storeBasePath)) { mkdir $storeBasePath | Out-Null } $json | Out-File $storePath Write-OK "Tenant created" # Configuration migration if ($webReport.NeedSecuritySet -eq $true) { Write-Verbose "Setting default security to Windows authentication" Set-P1WebAuthentication $Tenant -Windows } Write-Section "Migrating configuration..." Migrate-Configuration $Role Write-OK "Configuration migrated" # Install App Server New-P1ServerInstance -Tenant $Tenant -ERP $ERP Write-OK "Windows service created" Write-OK "Role $Role migrated" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1LegacyRole.ps1
Get-P1LegacyRole.ps1
function Get-P1LegacyRole { <# .Synopsis Get PlannerOne legacy role list and information. .Description Return the PlannerOne legacy (version < 5.1) role informations #> [cmdletbinding()] param( [string] $Role ) Process { $roleConfigPath = Get-LegacyRolePath if (Test-Path $roleConfigPath) { Write-Verbose "Reading $roleConfigPath" [xml] $Roles = Get-Content $roleConfigPath if ($Role) { return $Roles.ArrayOfKeyValueOfstringServiceInstallKuH_Pi4Ow.KeyValueOfstringServiceInstallKuH_Pi4Ow.Value | where { $_.Role -eq $Role } } else { return $Roles.ArrayOfKeyValueOfstringServiceInstallKuH_Pi4Ow.KeyValueOfstringServiceInstallKuH_Pi4Ow.Value } } else { Write-Warning "No legacy role definition found at $roleConfigPath" } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1AdapterParameters.ps1
Get-P1AdapterParameters.ps1
function Get-P1AdapterParameters { <# .Synopsis Get the adapter parameters. .Description Get the adapter parameters for tenant. .Parameter Tenant The target tenant. #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return } $tenantInfo = Get-TenantInfo $Tenant if ($tenantInfo -eq $null) { Write-Warning "No tenant information available" Write-Warning "Configuration cancel" return } $Adapter = $tenantInfo.Adapter [string] $path = "" if ($Adapter -eq "NAV") { $path = Get-NAVConfigurationPath $Tenant } if ($Adapter -eq "REST") { $path = Get-RESTConfigurationPath $Tenant } if ($Adapter -eq "AP") { $path = Get-APConfigurationPath $Tenant } if ($path -ne "") { Write-Verbose "Trying to read parameters in $path" if (Test-Path $path) { [string] $json = Get-Content $path if ($json -ne $null) { $parameters = ConvertFrom-JSon $json return $parameters } else { Write-Warning "No configuration" return $null } } else { Write-Warning "No configuration" return $null } } else { Write-Warning "No adapter type define for tenant" return $null } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Start-P1Manager.ps1
Start-P1Manager.ps1
function Start-P1Manager { <# .Synopsis Start PlannerOne manager for the given tenant. .Description Start PlannerOne manager for the given tenant. .Parameter Tenant The target tenant. .Example # Start PlannerOne manager for tenant named Prod. Start-P1Manager -Tenant Prod #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } # get bin path for the tenant $servicePath = Get-ServicePath $managerPath = "$servicePath\$Tenant\PlannerOneManager.exe" Start-Process $managerPath } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Set-P1LogLevel.ps1
Set-P1LogLevel.ps1
function Set-P1LogLevel { <# .Synopsis Set the log level of PlannerOne .Description Set the log level of PlannerOne service and PlannerOne Web. Standard level are Info and Debug. PlannerOne Web and Service must be restarted to take the new option into account. PlannerOne Web and Service will be restarted if option -Restart is set. Configuration is persisted and reapplied after a switch version. Use -NoPersist to change only the current installed version. The default value is Info. The following levels are defined in order of increasing priority: - ALL - DEBUG - INFO - WARN - ERROR - FATAL - OFF Current log level can be obtain with Get-P1LogLevel. .Parameter Tenant The target tenant. .Parameter Level The log level to set. .Parameter Restart Restart the PlannerOne Web Application and the PlannerOne Service after the new log level has been set. .Parameter NoPersist Do not persist the configuration for next upgrade. .Example # Set the tenant PROD to Debug and restart Set-P1LogLevel -Tenant PROD -Level DEBUG -Restart #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [Parameter(Mandatory=$true)] [string] $Level, [switch] $Restart, [switch] $NoPersist ) Process { Write-Section "Setting log level to $Level for tenant $Tenant" if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $levelOK = Test-LogLevel $Level if (!$levelOK) { Write-Warning "Log level is not correct." Write-LogLevels Write-Warning "Operation canceled." return } $info = Get-P1Tenant $Tenant $webApp = Get-P1WebApplication $Tenant if ($webApp -eq $null) { Write-KO "Cannot find the web application for tenant $Tenant" return } $webPath = $webApp.PhysicalPath Write-Verbose "Web physical path is $webPath" Write-Log4NetWeb $webPath $Level $servicePath = $info.Path Write-Verbose "Service physical path is $servicePath" Write-Log4NetService $servicePath $Level if (!$NoPersist) { Write-LogLevel $Tenant $Level } if ($Restart) { Restart-Tenant $webApp $info } Write-OK "Log level set to $Level for tenant $Tenant" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1MigrationReport.ps1
Get-P1MigrationReport.ps1
function Get-P1MigrationReport { <# .Synopsis Get PlannerOne migration reports. .Description Return the PlannerOne migration reports for tenant list or for tenant configuration .Parameter Tenant The tenant name. .Parameter Report The report name. .Example # Get the list of report for tenant Prod Get-P1MigrationReport -Tenant Prod #> [cmdletbinding()] param( [string] $Tenant, [string] $Report ) Process { if ($Tenant -eq "") { if ($Report -eq "") { Get-GlobalReportList Write-Output "Use Get-P1MigrationReport -Report [REPORT] to read report" Write-Output "Use Get-P1Tenant to get a list of available tenants" } else { Get-GlobalReport $Report } } else { if ($Report -eq "") { Get-ConfigReportList $Tenant Write-Output "Use Get-P1MigrationReport -Tenant $Tenant -Report [REPORT] to read report" } else { Get-ConfigReport $Tenant $Report } } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1AdapterStatus.ps1
Get-P1AdapterStatus.ps1
function Get-P1AdapterStatus { <# .Synopsis Get the PlannerOne adapter health status. .Description Work only for NAV. Get the PlannerOne adapter status. Global status is the base status of the adapter. It is on error in case of global error like network. Environments are the status for all environments. Status is the computed status based on previous one. It is the one shown in manager. .Parameter Tenant The PlannerOne tenant. .Example # Get adapter status of Prod Get-P1AdapterStatus PROD #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { Write-Section "Getting adapter status" if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $TenantInfo = Get-P1Tenant $Tenant $wsPort = $TenantInfo.WebServicePort Get-AdapterStatus $wsPort } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1Version.ps1
Get-P1Version.ps1
function Get-P1Version { <# .Synopsis Get the PlannerOne version for tenant. .Description Get the PlannerOne server version for tenant. .Parameter Tenant The tenant name. .Example # Get version of tenant Prod Get-P1Version Prod #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return } $info = Get-TenantInfo $Tenant if ($info -eq $null) { Write-Warning "No information registered for tenant $Tenant" return } $path = $info.Path $revisionPath = $path + "\revision.txt" if (!(Test-Path $revisionPath)) { Write-Warning "DEV - Trying to get SVN informations" $svnPath = $path + "\..\.." Invoke-Expression "svn info `"$svnPath`"" return } Get-Content $revisionPath } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Watch-P1ServerModel.ps1
Watch-P1ServerModel.ps1
function Watch-P1ServerModel { <# .Synopsis Watch the model versions on PlannerOne server. .Description Display for each environment loaded in PlannerOne the real model and cache versions. .Parameter Tenant The tenant to use to retrieve connection informations. .Parameter HostName The hostname to query (default localhost) .Parameter ServicePort The hostname port of REST Service (default 80) .Example Watch-P1ServerModel -ServicePort 8073 #> [cmdletbinding()] param( [string] $Tenant, [string] $HostName, [int] $ServicePort ) Process { if ($Tenant -ne "") { $info = Get-TenantInfo $Tenant if ($info -eq $null) { Write-Warning "No information registered for tenant $Tenant" return } $HostName = $info.ServiceHost $ServicePort = $info.WebServicePort } else { $Tenant = "NA" } if ($HostName -eq "") { $HostName = "localhost" } if ($ServicePort -eq 0) { $ServicePort = 80 } $url = 'http://' + $HostName + ':' + $ServicePort + '/Services/cache/all' $serviceUrl = FixUrl $url $auto = $true $continue = $true while($continue) { clear echo "Tenant: $Tenant - Host: $HostName - Port: $ServicePort" $lastRefresh = Get-Date echo "$lastRefresh - Version format: Planning | Static | Dynamic" $state = (wget $serviceUrl).Content $stateObj = $state | ConvertFrom-Json $displayArray = @() foreach ($env in $stateObj) { if ($env.Id.EnvironmentId.Kind -eq 1) { $kind = "PS" } else { $kind = "RP" } if ($env.Id.Nature -eq 1) { $nature = "Working" } else { $nature = "Published" } $real = Get-PlanningVersion $env.RealPlanningVersion $vo = Get-PlanningVersion $env.VOVersion $ro = Get-PlanningVersion $env.ReadOnlyVersion $displayObj = New-Object System.Object $displayObj | Add-Member -type NoteProperty -name Product -value $kind $displayObj | Add-Member -type NoteProperty -name Name -value $env.Id.EnvironmentId.Name $displayObj | Add-Member -type NoteProperty -name Group -value $env.Id.EnvironmentId.PlanningGroupContainer $displayObj | Add-Member -type NoteProperty -name Nature -value $nature $displayObj | Add-Member -type NoteProperty -name Real_Version -value $real $displayObj | Add-Member -type NoteProperty -name Cache_VOVersion -value $vo $displayObj | Add-Member -type NoteProperty -name Cache_ReadOnlyVersion -value $ro $displayArray += $displayObj } $displayArray | Format-Table echo "ESCAPE: Quit | R: Refresh | A: Auto-Refresh (5s): $auto" $counter = 0 if ($auto) { while(![console]::KeyAvailable -and ($counter++ -lt 10)) { [Threading.Thread]::Sleep( 500 ) } } if ([console]::KeyAvailable -or !$auto) { $x = [System.Console]::ReadKey() switch ($x.key) { # http://msdn.microsoft.com/en-us/library/system.consolekey(v=vs.110).aspx Escape { $continue = $false } R { } A { $auto = !$auto } } } } Write-Output "Watch end" # Write-Host must be call for ReadKey to not corrupt the console Write-Host } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/New-P1ManagerShortcut.ps1
New-P1ManagerShortcut.ps1
function New-P1ManagerShortcut { <# .Synopsis Creates a desktop shortcut to PlannerOne Manager, for a given tenant. .Description Creates a shortcut on the desktop. .Parameter Tenant The tenant name. .Example # Creates a PlannerOne Manager shortcut for tenant named Demo. New-P1Tenant -Tenant Demo #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } # get bin path for the tenant $servicePath = Get-ServicePath $managerPath = "$servicePath\$Tenant\PlannerOneManager.exe" $ShortcutFile = "$env:Public\Desktop\PlannerOne Manager - $Tenant.lnk" $WScriptShell = New-Object -ComObject WScript.Shell $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile) $Shortcut.TargetPath = $managerPath $Shortcut.Save() } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/New-P1Tenant.ps1
New-P1Tenant.ps1
function New-P1Tenant { <# .Synopsis Install a new PlannerOne tenant (service + web app). .Description Install a new PlannerOne tenant with the given parameters. One tenant should be: * One Windows service * One application pool * One web site * One web application Every name are set by convention from tenant name. You can force web application name for backward compatibility. Keep convention name if possible for easier maintenance. .Parameter Tenant The tenant name. .Parameter WebServicePort The port to be used by AppServer for REST API. .Parameter RemotingPort The port to be used by AppServer for Remoting API. .Parameter WebPort The customized port to be used by WebServer site. .Parameter WebAppName The customized name to use for web application. .Parameter ERP The ERP to use (NAV, AP, SAGE). .Example # Install a PlannerOne tenant named P1Prod. New-P1Tenant -Tenant P1Prod -ERP SAGE #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [int] $RemotingPort, [int] $WebServicePort, [int] $WebPort, [string] $WebAppName, [Parameter(Mandatory=$true)] [string] $ERP ) Process { if (Test-Tenant $Tenant) { Write-Warning "Tenant $Tenant already exist. Creation canceled." Write-Warning "Type Get-Help New-P1Tenant for more information." return } if ($ERP -eq "") { Write-Warning "ERP is not defined." Write-Warning "Please select call New-P1Tenant again with -ERP flag (NAV, AP, SAGE)" return } $erpValid = Test-ERPName $ERP if (!$erpValid) { Write-Warning "$ERP is not a valid value" Write-ERPNames Write-Warning "Operation canceled" return } $packageName = Get-PackageName $P1SrvPackage $ERP $package = Get-Package $packageName if ($package -eq $null) { Write-Warning "Package $packageName does not exist." Write-Warning "Call Install-P1Package with missing packages." return } $packageName = Get-PackageName $P1WebPackage $ERP $package = Get-Package $packageName if ($package -eq $null) { Write-Warning "Package $packageName does not exist." Write-Warning "Call Install-P1Package with missing packages." return } $iisCommand = Get-Command New-WebAppPool if ($iisCommand -eq $null) { Write-Warning "Command New-WebAppPool does not exist." Write-Warning "Please run Test-P1Prerequisites." return } Write-Section "Creating tenant..." if ($WebPort -eq 0) { $WebPort = $DefaultWebPort } if (!$WebAppName) { $WebAppName = Get-WebAppNameFromTenant $Tenant } # create web app before registering to get the good web port $webReport = New-P1WebApp -Tenant $Tenant -Port $WebPort -WebAppName $WebAppName -ERP $ERP $SitePort = $webReport.Port Write-OK "Web created on port $SitePort" if ($WebServicePort -eq 0) { $WebServicePort = $SitePort + 1 } if ($RemotingPort -eq 0) { $RemotingPort = $SitePort + 2 } # TODO: test that these 2 last ports are free $adapter = $ERPToAdapter.Get_Item($ERP) Write-Verbose "Adapter associated to ERP is $adapter" Write-Section "Registrating tenant..." Register-Tenant -Tenant $Tenant -RemotingPort $RemotingPort -WebServicePort $WebServicePort -WebAppName $WebAppName -SitePort $SitePort -Adapter $adapter Write-OK "Registration done" if ($webReport.NeedSecuritySet -eq $true) { Write-Verbose "Setting default security to Windows authentication" Set-P1WebAuthentication $Tenant -Windows } New-P1ServerInstance -Tenant $Tenant -ERP $ERP Write-OK "Windows service created" Write-Warning "Run 'Set-P1Adapter' to configure Adapter" Write-OK "Tenant '$Tenant' created" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Start-P1Tenant.ps1
Start-P1Tenant.ps1
function Start-P1Tenant { <# .Synopsis Start a PlannerOne tenant .Description Start a PlannerOne tenant by restarting web application and service. .Parameter Tenant The target tenant. #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { Write-Section "Starting tenant $Tenant" if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $info = Get-P1Tenant $Tenant $webApp = Get-P1WebApplication $Tenant if ($webApp -eq $null) { Write-KO "Cannot find the web application for tenant $Tenant" return } Start-P1ServiceInternal $info Start-P1WebInternal $webApp Write-OK "Tenant $Tenant started" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Set-P1WebSSL.ps1
Set-P1WebSSL.ps1
function Set-P1WebSSL { <# .Synopsis Enable or disable SSL for the PlannerOne Web server. .Description Enable or disable SSL for PlannerOne web application. Set certificate and binding on web site. Change REST web service security accordingly. .Parameter Tenant The target tenant. .Parameter Enable Enable SSL. .Parameter Disable Disable SSL. .Parameter SSLPort The port of binding. By default 443. .Parameter CertificateStore The store to use to get certificate. By default 'My' .Parameter CertificateFriendlyName The certificate friendly name to associate to binding. Exclusive option with thumbprint. .Parameter CertificateThumbprint The certificate thumbprint to associate to binding. Exclusive option with FriendlyName. .Parameter HostedIP The hosted ip associate to binding's certificate. 0.0.0.0 if not define. .Example # Enable SSL Set-P1WebSSL -Tenant Prod -Enable -CertificateFriendlyName server-prod-certif -Store Root .Example # Disable SSL on port 8443 Set-P1WebSSL -tenant PROD -Disable -SSLPort 8443 #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [switch] $Enable, [switch] $Disable, [int] $SSLPort, [string] $CertificateStore, [string] $CertificateFriendlyName, [string] $CertificateThumbprint, [string] $HostedIP ) Process { Write-Section "Setting Web Application SSL" if ($Enable -and $Disable) { Write-Warning "You can only choose one option." return } if (!($Enable -or $Disable)) { Write-Warning "You need to choose one option." return } if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } Set-WebSSLInternal -Tenant $Tenant -Enable:$Enable.IsPresent -Disable:$Disable.IsPresent -SSLPort $SSLPort -CertificateStore $CertificateStore -CertificateFriendlyName $CertificateFriendlyName -CertificateThumbprint $CertificateThumbprint -HostedIP $HostedIP Register-P1WebServices $Tenant Write-OK "Web SSL enabled for tenant $Tenant" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Get-P1Tenant.ps1
Get-P1Tenant.ps1
function Get-P1Tenant { <# .Synopsis Get PlannerOne tenant list and information. .Description Return the PlannerOne tenants informations .Parameter Tenant The tenant name. .Example # Get the list of tenants Get-P1Tenant .Example # Get a tenant information Get-P1Tenant -Tenant "PlannerOneProd" #> [cmdletbinding()] param( [string] $Tenant ) Process { $tenantsPath = Get-TenantsPath if (!(Test-Path $tenantsPath)) { return } if ($Tenant -eq "") { Get-TenantList } else { $info = Get-TenantInfo $Tenant if ($null -ne $info) { $revisionPath = $info.Path + "\revision.txt" if (Test-Path $revisionPath) { $revision = Get-Content $revisionPath Write-Output "Version: $revision" } } $info } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Install-P1Package.ps1
Install-P1Package.ps1
function Install-P1Package { <# .Synopsis Get all required packages from PlannerOne NuGet server. .Description Connect to remote repository and get the latest release. .Parameter Package The PlannerOne package list. .Parameter ERP The target ERP to get default packages for if not provided in Package list (NAV, AP, SAGE) .Parameter Version The ERP version .Parameter Source Force source for package. .Parameter NoERPModules Do not install specific ERP modules, only PlannerOne server and web application. .Example # Install PlannerOne server, web and NAV 2016 objects Install-P1Package PlannerOne.Server,PlannerOne.WebApp,PlannerOne.NAV.2016 .Example # Install PlannerOne SAGE server and web Install-P1Package -ERP SAGE #> [cmdletbinding()] param( [Parameter(Mandatory=$False)] [string[]] $Package, [Parameter(Mandatory=$False)] [string] $ERP, [Parameter(Mandatory=$False)] [string] $Version='', [string] $Source, [switch] $NoERPModules, [switch] $LocalSource ) Process { if ($Source -ne "") { if ($LocalSource) { $sourceName = "PlannerOneLocal" } else { $sourceName = "PlannerOneCustom" } } else { $sourceName = "PlannerOne" } $feedUrl = Get-FeedUrl $Source if ($feedUrl -eq "") { return } else { try { $plannerOneSource = Get-PackageSource $sourceName -ErrorAction "SilentlyContinue" } catch {} if ($plannerOneSource -eq $null) { Write-Verbose "Registering $feedUrl as a trusted package source for $sourceName." Register-PackageSource -Name $sourceName -Trusted -ProviderName NuGet -Location $feedUrl | Out-Null } } if ($null -eq $Package) { if ($ERP -eq "") { Write-Warning "No package specified and no ERP Specified. Cannot continue." return } else { $erpValid = Test-ERPName $ERP if (!$erpValid) { Write-Warning "$ERP is not a valid value" Write-ERPNames Write-Warning "Operation canceled" return } } $packageSrvWeb = Get-PackageName $P1SrvPackage $ERP $packageWebName = Get-PackageName $P1WebPackage $ERP $Package = @( $packageSrvWeb; $packageWebName; ) if($ERP.ToUpper() -eq "NAV" -and !$NoERPModules){ if($Version -eq ""){ Write-Warning "If you use NAV adapter, you need to specify its version." Write-Warning "If you do not want to install NAV package run Install-P1Package PlannerOne.NAV.Server,PlannerOne.NAV.WebApp" Write-Warning "Cannot continue." return }elseif(!(Test-NavVersionCompatibility $Version)){ Write-Warning "The NAV version $Version is not compatible with this script." Write-Warning "If you do not want to install NAV package run Install-P1Package PlannerOne.NAV.Server,PlannerOne.NAV.WebApp" Write-Warning "The compatible version are $($SupportedNavVersions -join ", "). Cannot continue." return }else{ $Package += Get-Version $P1NavToolPackage $Version } } } Write-Section "Getting PlannerOne packages ($($Package -join ", "))..." if (Get-Command Install-Package -errorAction SilentlyContinue) { Write-Verbose "Install-Package exists" foreach($Pack in $Package) { Write-Output "Installing $Pack..." $installedPackage = Install-Package $Pack -Source $feedUrl if ($LocalSource -and $Source -ne "") { # Due to a bug in nuget provider, nupkg is not copied during an install from local file system source if ($installedPackage -ne $null) { Copy-Item $Source\$Pack* $installedPackage.FullPath } } $Folder = Get-PackageFolder $Pack Write-OK "Package installed in $Folder" } } else { Write-Output "Install-Package doesn't exist, using NuGet" foreach($Pack in $Package) { Write-Output "Installing $Pack..." NuGet install $Pack -Source $feedUrl } } Write-OK "Packages installed" foreach($Pack in $Package){ if($Pack -match 'PlannerOne.NAV.(\d{4})') { $year = $Pack.ToUpper().replace("PLANNERONE.NAV.","") Import-P1NavTool $year } } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Remove-P1ServerInstance.ps1
Remove-P1ServerInstance.ps1
function Remove-P1ServerInstance { <# .Synopsis Uninstall a existing PlannerOne service. .Description Uninstall a existing PlannerOne service with the given parameters. .Parameter Tenant The tenant name of this service. .Example # Uninstall a PlannerOne service for the tenant Prod. Remove-P1ServerInstance -Tenant Prod #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { Write-Section "Removing server instance..." $serviceName = Get-ServiceNameFromTenant $Tenant $servicePath = Get-ServicePath #Test if service exists if (Test-ServiceExists($ServiceName)) { Stop-Service -Name $ServiceName -Force $serviceApp = Get-Service -Name $ServiceName Write-Output "Waiting 5 seconds for service to really stop." Start-Sleep -seconds 5 Write-Verbose "Deleting PlannerOne service for Tenant $Tenant" Remove-Service($ServiceName) | Out-Null # Remove Service folder Write-Verbose "Removing folder: $servicePath\$Tenant" Remove-Symlink "$servicePath\$Tenant" Write-OK "Server instance removed" } else { # Always try to remove symlink Remove-Symlink "$servicePath\$Tenant" Write-Warning "Service $ServiceName doesn't exist!" } } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Set-P1Adapter.ps1
Set-P1Adapter.ps1
function Set-P1Adapter { <# .Synopsis Configuration of the adapter for the ERP. .Description Configure the adapter for PlannerOne. .Parameter Tenant The tenant name. .Parameter Server The ERP host server name. .Parameter SOAPPort The ERP Web service SOAP port. .Parameter RESTPort The ERP Web service SOAP port. .Parameter AuthenticationMode The ERP authentication mode (Certificate, Negotiate, NTLM, Digest, Basic). .Parameter SSL Does the ERP server use SSL. .Parameter ClientPort The port for external client software (RTC...) .Parameter InstanceName The ERP server instance name. .Parameter ERPTenantName The ERP tenant name. .Parameter ServiceDomain The PlannerOne technical account domain. .Parameter ServiceLogin The PlannerOne technical account login. .Parameter ServicePassword The PlannerOne technical account password. .Parameter AutoPort Read ports from ERP configuration provided with InstanceName .Parameter WebServer The ERP web server host .Parameter WebPort The ERP web server port .Parameter WebSite The ERP web site .Parameter BulkPath The ERP bulk path for data .Parameter ExtraParameter Extra parameter specific for ERP. For NAV, to specify NAVVersion of Powershell module tools to use: -ExtraParameter "NAVVersion=90" .Example # Configure an adapter Set-P1Adapter -Tenant nodb -ServiceDomain ORTEMS -ServiceLogin PlannerOne -ServicePassword Planner1 -Server locahost -InstanceName ERPInstance -SOAPPort 9047 "Configure for AP Set-P1Adapter -Tenant APTenant -Server localhost -SOAPPort 2039 -ServiceLogin "ap\planadm" -ServicePassword planadm -WebServer loalhost -WebPort 80 -WebSite APPlus -BulkPath "c:\temp\p1data" #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [string] $Server, [int] $SOAPPort, [int] $RESTPort, [string] $AuthenticationMode, [bool] $SSL, [int] $ClientPort, [string] $InstanceName, [string] $ERPTenantName, [string] $ServiceDomain, [string] $ServiceLogin, [string] $ServicePassword, [switch] $AutoPort, [string] $WebServer, [int] $WebPort, [string] $WebSite, [string] $BulkPath, [string] $ExtraParameter ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return } $tenantInfo = Get-TenantInfo $Tenant if ($tenantInfo -eq $null) { Write-Warning "No tenant information available" Write-Warning "Configuration cancel" return } $Adapter = $tenantInfo.Adapter if ($Adapter -eq "" -or $Adapter -eq $null) { Write-Warning "Adapter is not defined" return } if ($Adapter -ne "NAV" -and $Adapter -ne "REST" -and $Adapter -ne "AP") { Write-Warning "Adapter $Adapter not recognized" return } if ($AuthenticationMode -eq "Certificate") { if ($Adapter -ne "REST") { Write-Warning "Certificate authentication is only available for REST adapter." return } $SSL = $true } if ($Adapter -eq "NAV") { Write-Section "Configuring NAV Adapter..." if ($InstanceName -eq "") { Write-Warning "Microsoft Dynamics NAV Instance name is missing." return } [string] $NAVVersion = "" if ($ExtraParameter -ne "") { Write-Verbose "Parsing ExtraParameter $ExtraParameter" $splited = $ExtraParameter.Split("=") if ($splited[0] -eq "NAVVersion" -and $splited.Length -ge 2) { $NAVVersion = $splited[1] Write-Verbose "NAVVersion is set to $NAVVersion" } } $NAVConfig = Get-NAVParametersFromConfig -InstanceName $InstanceName -NAVVersion $NAVVersion if ($AutoPort) { if ($NAVConfig -eq $null) { Write-Warning "No NAV configuration. PlannerOne AutoPort Configuration canceled." return } $InstanceName = $NAVConfig.InstanceName $SOAPPort = $NAVConfig.SOAPPort $ClientPort = $NAVConfig.ClientPort } if ($NAVConfig -ne $null) { if ($NAVConfig.SOAPPort -ne $SOAPPort) { $port = $NAVConfig.SOAPPort Write-Warning "SOAP Port $SOAPPort is not the one set for Microsoft Dynamics NAV instance $InstanceName`: $port" Write-Warning "You can use -AutoPort switch to automatically use the ports configured in Microsoft Dynamics NAV." Write-Warning "PlannerOne adapter configuration canceled." return; } if ($NAVConfig.SOAPServicesEnabled -ne "true") { Write-Warning "SOAP service is not enabled in Microsoft Dynamics NAV instance $InstanceName" Write-Warning "PlannerOne adapter configuration canceled." return; } if ($NAVConfig.ServicesDefaultTimeZone -ne "Server Time Zone") { $timezone = $NAVConfig.ServicesDefaultTimeZone Write-Warning "SOAP service time zone should be 'Server Time Zone'. Current value in Microsoft Dynamics NAV instance $InstanceName`: $timezone" Write-Warning "PlannerOne adapter configuration canceled." return; } } else { Write-Warning "Cannot read Microsoft Dynamics NAV configuration: parameters won't be validated. Run with -verbose for more technical informations." } Set-NAVParameters $Tenant $Server $SOAPPort $AuthenticationMode $SSL $ClientPort $InstanceName $ServiceDomain $ServiceLogin $ServicePassword $ERPTenantName } if ($Adapter -eq "REST") { Write-Section "Configuring REST Adapter..." if ($AuthenticationMode -eq "") { $AuthenticationMode = "Basic" } if ($RESTPort -eq 0 -and $SOAPPort -ne 0) { $RESTPort = $SOAPPort } Set-RESTParameters $Tenant $Server $RESTPort $AuthenticationMode $SSL $InstanceName $ServiceDomain $ServiceLogin $ServicePassword $ERPTenantName } if ($Adapter -eq "AP") { Write-Section "Configuring AP Adapter..." if ($Login -eq "") { Write-Warning "Login is missing. Operation canceled" return } if ($Password -eq "") { Write-Warning "Password is missing. Operation canceled" return } if ($WebSite -eq "") { Write-Warning "WebSite is missing. Operation canceled" return } if ($BulkPath -eq "") { Write-Warning "BulkPath is missing. Operation canceled" return } Set-APParameters $Tenant $Server $SOAPPort $ServiceLogin $ServicePassword $WebServer $WebPort $WebSite $BulkPath } $serviceName = Get-ServiceNameFromTenant $Tenant Write-Output "Restarting PlannerOne service $serviceName..." Stop-Service -Name $ServiceName -Force Write-Output "Waiting 5 seconds for service to really stop." Start-Sleep -seconds 5 Start-Service -Name $serviceName Write-OK "Configuration done" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Stop-P1Tenant.ps1
Stop-P1Tenant.ps1
function Stop-P1Tenant { <# .Synopsis Stop a PlannerOne tenant .Description Stop a PlannerOne tenant by restarting web application and service. .Parameter Tenant The target tenant. #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant ) Process { Write-Section "Stopping tenant $Tenant" if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return; } $info = Get-P1Tenant $Tenant $webApp = Get-P1WebApplication $Tenant if ($webApp -eq $null) { Write-KO "Cannot find the web application for tenant $Tenant" return } Stop-P1ServiceInternal $info Stop-P1WebInternal $webApp Write-OK "Tenant $Tenant stopped" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Export-P1Environment.ps1
Export-P1Environment.ps1
function Export-P1Environment { <# .Synopsis Export PlannerOne environment to file. .Description Export an existing and initialized environment save it to file system. Each environments found for Production Scheduler and ResourcePlanner will be exported in its own file in -OutDir directory. .Parameter Tenant The tenant name to export. .Parameter OutDir The root directory path to use for export. .\p1EnvExport by default. #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [string] $OutDir ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." return } Write-Section "Exporting environments..." if ($OutDir -eq "") { $OutDir = ".\p1EnvExport" } if (!(Test-Path $OutDir)) { md $OutDir | Out-Null } $sourcePath = Get-EnvironmentsPathFromTenant $Tenant $sourcePath = $sourcePath + "*" Copy-Item -Recurse $sourcePath $OutDir Write-Section "Export finished" } }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Start-P1TenantManager.ps1
Start-P1TenantManager.ps1
function Start-P1TenantManager { [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework') [xml]$mainXaml = Get-Content "$PSScriptRoot\UI\MainWindow.xaml" [xml]$tenantXaml = Get-Content "$PSScriptRoot\UI\Tenant.xaml" $reader=(New-Object System.Xml.XmlNodeReader $mainXaml) try { $mainForm=[Windows.Markup.XamlReader]::Load( $reader ) } catch { Write-Warning "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed." } $reader=(New-Object System.Xml.XmlNodeReader $tenantXaml) try { $tenantForm=[Windows.Markup.XamlReader]::Load( $reader ) } catch { Write-Warning "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed." } # Store Form Objects In PowerShell $mainXaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name ($_.Name) -Value $mainForm.FindName($_.Name)} $tenantXaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name ($_.Name) -Value $tenantForm.FindName($_.Name)} # Close event $btnExit.Add_Click({$mainForm.Close()}) # Test click event $btnTest.Add_Click({ $features = Test-P1Prerequisites $prereqDataGrid.ItemsSource = @($features) }) # Add missing click event $btnAddMissing.Add_Click({ $prereqDataGrid.ItemsSource = $null $features = Test-P1Prerequisites -Install $prereqDataGrid.ItemsSource = @($features) }) # Test click event $btnLoad.Add_Click({ $packages = Get-P1Packages $itemsSource = @() foreach ($package in $packages) { $installedPackage = Get-Package $package.Name if ($installedPackage -ne $null) { $installedVersion = $installedPackage.Version } else { $installedVersion = $null } [PSCustomObject]$item = @{ Name = $package.Name; Version = $package.Version; InstalledVersion = $installedVersion; Install = $false; } $itemsSource += $item } $packagesDataGrid.ItemsSource = $itemsSource }) # Install click event $btnInstall.Add_Click({ $itemsSource = $packagesDataGrid.ItemsSource foreach ($package in ($itemsSource | Where-Object Install -eq $true)) { Install-P1Package $package.Name } }) $btnLoadTenants.Add_Click({ $tenants = Get-P1Tenant $tenantsDataGrid.ItemsSource = $tenants }) # New tenant $btnNewTenant.Add_Click({ $NameTxt.Text = "Demo" $AdapterTxt.Text = "NAV" $InstanceTxt.Text = "NAV" $DomainTxt.Text = $env:USERDOMAIN $LoginTxt.Text = $env:USERNAME $PasswordTxt.Text = "<YourPassword>" $tenantForm.ShowDialog() | Out-Null }) $CancelBtn.Add_Click({ $tenantForm.Hide() }) $CreateBtn.Add_Click({ New-P1Tenant -Tenant $NameTxt.Text -Adapter $AdapterTxt.Text Set-P1Adapter -Tenant $NameTxt.Text -InstanceName $InstanceTxt.Text -AutoPort -ServiceDomain $DomainTxt.Text -ServiceLogin $LoginTxt.Text -ServicePassword $PasswordTxt.Text $tenantForm.Hide() }) $mainForm.ShowDialog() | Out-Null }
PowerShellCorpus/PowerShellGallery/PlannerOne.Deployment/1.0.151/Public/Compress-P1Logs.ps1
Compress-P1Logs.ps1
function Compress-P1Logs { <# .Synopsis Archive to zip the logs for a tenant .Description Zip all PlannerOne logs for tenant in a given file .Parameter Tenant The tenant name. .Parameter OutFile The zip file to write. .Example # Zip Prod logs Archive-P1Logs -Tenant Prod -OutFile c:\temp\prodlogs.zip #> [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string] $Tenant, [Parameter(Mandatory=$true)] [string] $OutFile ) Process { if (!(Test-Tenant $Tenant)) { Write-Warning "Tenant $Tenant does not exist." Write-Warning "Operation canceled." return } $path = Get-LogPathFromTenant $Tenant if (!(Test-Path $path)) { Write-Warning "No logs to compress." return } Compress-Archive -Path $path -DestinationPath $OutFile } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Examples/Sample_BizTalkServerHost.ps1
Sample_BizTalkServerHost.ps1
Configuration BizTalkServerHostExample { Import-DSCResource -ModuleName BizTalkServer BizTalkServerHost SampleBizTalkServerHost { Name = 'SampleBizTalkServerApplication' Ensure = 'Present' Is32Bit = $false Trusted = $true Tracking = $true Type = 'InProcess' Default = $false WindowsGroup = 'BizTalk Application Users' } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Examples/Sample_BizTalkServerReceiveHandler.ps1
Sample_BizTalkServerReceiveHandler.ps1
Configuration BizTalkServerReceiveHandlerExample { Import-DSCResource -ModuleName BizTalkServer BizTalkServerAdapter SampleBizTalkServerAdapter { Name = 'WCF-SQL' Ensure = 'Present' MgmtCLSID = '{59B35D03-6A06-4734-A249-EF561254ECF7}' } BizTalkServerHost SampleBizTalkServerHost { Name = 'BizTalkServerApplication2' Trusted = $true Tracking = $false Type = 'InProcess' Is32Bit = $true Default = $true WindowsGroup = 'BizTalk Application Users' Ensure = 'Present' } BizTalkServerReceiveHandler SampleBizTalkServerReceiveHandler { DependsOn = @('[BizTalkServerAdapter]SampleBizTalkServerAdapter','[BizTalkServerHost]SampleBizTalkServerHost') Adapter = 'WCF-SQL' Host = 'BizTalkServerApplication2' Ensure = 'Present' } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Examples/Sample_BizTalkServerSendHandler.ps1
Sample_BizTalkServerSendHandler.ps1
Configuration BizTalkServerSendHandlerExample { Import-DSCResource -ModuleName BizTalkServer BizTalkServerAdapter SampleBizTalkServerAdapter { Name = 'WCF-SQL' Ensure = 'Present' MgmtCLSID = '{59B35D03-6A06-4734-A249-EF561254ECF7}' } BizTalkServerHost SampleBizTalkServerHost { Name = 'BizTalkServerApplication2' Trusted = $true Tracking = $false Type = 'InProcess' Is32Bit = $true Default = $true WindowsGroup = 'BizTalk Application Users' Ensure = 'Present' } BizTalkServerSendHandler SampleBizTalkServerSendHandler { DependsOn = @('[BizTalkServerAdapter]SampleBizTalkServerAdapter','[BizTalkServerHost]SampleBizTalkServerHost') Adapter = 'WCF-SQL' Host = 'BizTalkServerApplication2' Default = $true Ensure = 'Present' } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Examples/Sample_BizTalkServerAdapter.ps1
Sample_BizTalkServerAdapter.ps1
Configuration BizTalkServerAdapterExample { Import-DSCResource -ModuleName BizTalkServer BizTalkServerAdapter SampleBizTalkServerAdapter { Name = 'WCF-SQL' Ensure = 'Present' MgmtCLSID = '{59B35D03-6A06-4734-A249-EF561254ECF7}' } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Examples/Sample_BizTalkServerHostInstance.ps1
Sample_BizTalkServerHostInstance.ps1
$password = ConvertTo-SecureString 'Pass@word1' -AsPlainText -Force $credentials = New-Object System.Management.Automation.PSCredential ('.\Administrator', $password) Configuration BizTalkServerHostExample { Import-DSCResource -ModuleName BizTalkServer BizTalkServerHost SampleBizTalkServerHost { Name = 'SampleBizTalkServerApplication' Ensure = 'Present' Is32Bit = $false Trusted = $true Tracking = $true Type = 'InProcess' Default = $false WindowsGroup = 'BizTalk Application Users' } BizTalkServerHostInstance SampleBizTalkServerHostInstance { DependsOn = @('[BizTalkServerHost]SampleBizTalkServerHost') Ensure = 'Present' Host = 'SampleBizTalkServerApplication' Credential = $credentials } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerHost.integration.tests.ps1
MSFT_BizTalkServerHost.integration.tests.ps1
<# .Synopsis Template for creating DSC Resource Integration Tests .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.Integration.tests.ps1 (e.g. MSFT_xNeworking.Integration.tests.ps1) 2. Customize TODO sections. 3. Create test DSC Configurtion file <ResourceName>.config.ps1 (e.g. MSFT_xNeworking.config.ps1) from integration_config_template.ps1 file. .NOTES Code in HEADER, FOOTER and DEFAULT TEST regions are standard and may be moved into DSCResource.Tools in Future and therefore should not be altered if possible. #> $script:DSCModuleName = 'BizTalkServer' $script:DSCResourceName = 'MSFT_BizTalkServerHost' #region HEADER # Integration Test Template Version: 1.1.1 [String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) } Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force $TestEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:DSCModuleName ` -DSCResourceName $script:DSCResourceName ` -TestType Integration #endregion # TODO: Other Init Code Goes Here... # Using try/finally to always cleanup. try { #region Integration Tests $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" . $configFile Describe "$($script:DSCResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile and apply the MOF without throwing' { { & "$($script:DSCResourceName)_Config" -OutputPath $TestEnvironment.WorkingFolder Start-DscConfiguration -Path $TestEnvironment.WorkingFolder ` -ComputerName localhost -Wait -Verbose -Force } | Should not throw } It 'Should be able to call Get-DscConfiguration without throwing' { { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw } #endregion It 'Should have set the resource and all the parameters should match' { } } #endregion } finally { #region FOOTER Restore-TestEnvironment -TestEnvironment $TestEnvironment $query = "SELECT * FROM MSBTS_HostSetting WHERE Name='TestBizTalkServerApplication'" $instance = Get-CimInstance -Query $query -Namespace 'ROOT\MicrosoftBizTalkServer' if($null -ne $instance){ Remove-CimInstance -InputObject $instance } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerReceiveHandler.integration.tests.ps1
MSFT_BizTalkServerReceiveHandler.integration.tests.ps1
<# .Synopsis Template for creating DSC Resource Integration Tests .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.Integration.tests.ps1 (e.g. MSFT_xNeworking.Integration.tests.ps1) 2. Customize TODO sections. 3. Create test DSC Configurtion file <ResourceName>.config.ps1 (e.g. MSFT_xNeworking.config.ps1) from integration_config_template.ps1 file. .NOTES Code in HEADER, FOOTER and DEFAULT TEST regions are standard and may be moved into DSCResource.Tools in Future and therefore should not be altered if possible. #> $script:DSCModuleName = 'BizTalkServer' $script:DSCResourceName = 'MSFT_BizTalkServerReceiveHandler' #region HEADER # Integration Test Template Version: 1.1.1 [String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) } Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force $TestEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:DSCModuleName ` -DSCResourceName $script:DSCResourceName ` -TestType Integration #endregion # TODO: Other Init Code Goes Here... # Using try/finally to always cleanup. try { #region Integration Tests $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" . $configFile Describe "$($script:DSCResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile and apply the MOF without throwing' { { & "$($script:DSCResourceName)_Config" -OutputPath $TestEnvironment.WorkingFolder Start-DscConfiguration -Path $TestEnvironment.WorkingFolder ` -ComputerName localhost -Wait -Verbose -Force } | Should not throw } It 'Should be able to call Get-DscConfiguration without throwing' { { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw } #endregion It 'Should have set the resource and all the parameters should match' { } } #endregion } finally { #region FOOTER Restore-TestEnvironment -TestEnvironment $TestEnvironment $query = "SELECT * FROM MSBTS_SendHandler2 WHERE AdapterName = 'WCF-SQL' AND HostName = 'BizTalkServerApplication2'" $instance = Get-CimInstance -Query $query -Namespace 'ROOT\MicrosoftBizTalkServer' if($null -ne $instance){ Remove-CimInstance -InputObject $instance } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerReceiveHandler.config.ps1
MSFT_BizTalkServerReceiveHandler.config.ps1
<# .Synopsis DSC Configuration Template for DSC Resource Integration tests. .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.config.ps1 (e.g. MSFT_xFirewall.config.ps1) 2. Customize TODO sections. .NOTES #> # Integration Test Config Template Version: 1.0.0 configuration MSFT_BizTalkServerReceiveHandler_config { Import-DscResource -ModuleName 'BizTalkServer' node localhost { BizTalkServerAdapter TestBizTalkServerAdapter { Name = 'WCF-SQL' Ensure = 'Present' MgmtCLSID = '{59B35D03-6A06-4734-A249-EF561254ECF7}' } BizTalkServerHost TestBizTalkServerHost { Name = 'BizTalkServerApplication2' Trusted = $true Tracking = $false Type = 'InProcess' Is32Bit = $true Default = $true WindowsGroup = 'BizTalk Application Users' Ensure = 'Present' } BizTalkServerReceiveHandler TestBizTalkServerSendHandler { DependsOn = @('[BizTalkServerAdapter]TestBizTalkServerAdapter','[BizTalkServerHost]TestBizTalkServerHost') Adapter = 'WCF-SQL' Host = 'BizTalkServerApplication2' Ensure = 'Present' } } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerSendHandler.integration.tests.ps1
MSFT_BizTalkServerSendHandler.integration.tests.ps1
<# .Synopsis Template for creating DSC Resource Integration Tests .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.Integration.tests.ps1 (e.g. MSFT_xNeworking.Integration.tests.ps1) 2. Customize TODO sections. 3. Create test DSC Configurtion file <ResourceName>.config.ps1 (e.g. MSFT_xNeworking.config.ps1) from integration_config_template.ps1 file. .NOTES Code in HEADER, FOOTER and DEFAULT TEST regions are standard and may be moved into DSCResource.Tools in Future and therefore should not be altered if possible. #> $script:DSCModuleName = 'BizTalkServer' $script:DSCResourceName = 'MSFT_BizTalkServerSendHandler' #region HEADER # Integration Test Template Version: 1.1.1 [String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) } Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force $TestEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:DSCModuleName ` -DSCResourceName $script:DSCResourceName ` -TestType Integration #endregion # TODO: Other Init Code Goes Here... # Using try/finally to always cleanup. try { #region Integration Tests $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" . $configFile Describe "$($script:DSCResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile and apply the MOF without throwing' { { & "$($script:DSCResourceName)_Config" -OutputPath $TestEnvironment.WorkingFolder Start-DscConfiguration -Path $TestEnvironment.WorkingFolder ` -ComputerName localhost -Wait -Verbose -Force } | Should not throw } It 'Should be able to call Get-DscConfiguration without throwing' { { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw } #endregion It 'Should have set the resource and all the parameters should match' { } } #endregion } finally { #region FOOTER Restore-TestEnvironment -TestEnvironment $TestEnvironment $query = "SELECT * FROM MSBTS_SendHandler2 WHERE AdapterName = 'WCF-SQL' AND HostName = 'BizTalkServerApplication2'" $instance = Get-CimInstance -Query $query -Namespace 'ROOT\MicrosoftBizTalkServer' if($null -ne $instance){ Remove-CimInstance -InputObject $instance } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerSendHandler.config.ps1
MSFT_BizTalkServerSendHandler.config.ps1
<# .Synopsis DSC Configuration Template for DSC Resource Integration tests. .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.config.ps1 (e.g. MSFT_xFirewall.config.ps1) 2. Customize TODO sections. .NOTES #> # Integration Test Config Template Version: 1.0.0 configuration MSFT_BizTalkServerSendHandler_config { Import-DscResource -ModuleName 'BizTalkServer' node localhost { BizTalkServerAdapter TestBizTalkServerAdapter { Name = 'WCF-SQL' Ensure = 'Present' MgmtCLSID = '{59B35D03-6A06-4734-A249-EF561254ECF7}' } BizTalkServerHost TestBizTalkServerHost { Name = 'BizTalkServerApplication2' Trusted = $true Tracking = $false Type = 'InProcess' Is32Bit = $true Default = $true WindowsGroup = 'BizTalk Application Users' Ensure = 'Present' } BizTalkServerSendHandler TestBizTalkServerSendHandler { DependsOn = @('[BizTalkServerAdapter]TestBizTalkServerAdapter','[BizTalkServerHost]TestBizTalkServerHost') Adapter = 'WCF-SQL' Host = 'BizTalkServerApplication2' Default = $false Ensure = 'Present' } } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerHostInstance.config.ps1
MSFT_BizTalkServerHostInstance.config.ps1
<# .Synopsis DSC Configuration Template for DSC Resource Integration tests. .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.config.ps1 (e.g. MSFT_xFirewall.config.ps1) 2. Customize TODO sections. .NOTES #> # Integration Test Config Template Version: 1.0.0 configuration MSFT_BizTalkServerHostInstance_config { Import-DscResource -ModuleName 'BizTalkServer' $name = 'TestBizTalkServerApplication' node localhost{ $password = ConvertTo-SecureString 'Pass@word1' -AsPlainText -Force $credentials = New-Object System.Management.Automation.PSCredential ('Administrator', $password) BizTalkServerHost TestBizTalkServerHost { Name = $name Ensure = 'Present' Is32Bit = $false Trusted = $true Tracking = $true Type = 'InProcess' Default = $false WindowsGroup = 'BizTalk Application Users' } BizTalkServerHostInstance TestBizTalkServerHostInstance{ DependsOn = @('[BizTalkServerHost]TestBizTalkServerHost') Ensure = 'Present' Host = $name Credential = $credentials } } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerAdapter.config.ps1
MSFT_BizTalkServerAdapter.config.ps1
<# .Synopsis DSC Configuration Template for DSC Resource Integration tests. .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.config.ps1 (e.g. MSFT_xFirewall.config.ps1) 2. Customize TODO sections. .NOTES #> # Integration Test Config Template Version: 1.0.0 configuration MSFT_BizTalkServerAdapter_config { Import-DscResource -ModuleName 'BizTalkServer' node localhost { BizTalkServerAdapter TestBizTalkServerAdapter { Name = 'WCF-SQL' Ensure = 'Present' MgmtCLSID = '{59B35D03-6A06-4734-A249-EF561254ECF7}' } } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerAdapter.integration.tests.ps1
MSFT_BizTalkServerAdapter.integration.tests.ps1
<# .Synopsis Template for creating DSC Resource Integration Tests .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.Integration.tests.ps1 (e.g. MSFT_xNeworking.Integration.tests.ps1) 2. Customize TODO sections. 3. Create test DSC Configurtion file <ResourceName>.config.ps1 (e.g. MSFT_xNeworking.config.ps1) from integration_config_template.ps1 file. .NOTES Code in HEADER, FOOTER and DEFAULT TEST regions are standard and may be moved into DSCResource.Tools in Future and therefore should not be altered if possible. #> $script:DSCModuleName = 'BizTalkServer' $script:DSCResourceName = 'MSFT_BizTalkServerAdapter' #region HEADER # Integration Test Template Version: 1.1.1 [String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) } Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force $TestEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:DSCModuleName ` -DSCResourceName $script:DSCResourceName ` -TestType Integration #endregion # TODO: Other Init Code Goes Here... # Using try/finally to always cleanup. try { #region Integration Tests $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" . $configFile Describe "$($script:DSCResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile and apply the MOF without throwing' { { & "$($script:DSCResourceName)_Config" -OutputPath $TestEnvironment.WorkingFolder Start-DscConfiguration -Path $TestEnvironment.WorkingFolder ` -ComputerName localhost -Wait -Verbose -Force } | Should not throw } It 'Should be able to call Get-DscConfiguration without throwing' { { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw } #endregion It 'Should have set the resource and all the parameters should match' { } } #endregion } finally { #region FOOTER Restore-TestEnvironment -TestEnvironment $TestEnvironment $query = "SELECT * FROM MSBTS_AdapterSetting WHERE Name='WCF-SQL'" $instance = Get-CimInstance -Query $query -Namespace 'ROOT\MicrosoftBizTalkServer' if($null -ne $instance){ Remove-CimInstance -InputObject $instance } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerHostInstance.integration.tests.ps1
MSFT_BizTalkServerHostInstance.integration.tests.ps1
<# .Synopsis Template for creating DSC Resource Integration Tests .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.Integration.tests.ps1 (e.g. MSFT_xNeworking.Integration.tests.ps1) 2. Customize TODO sections. 3. Create test DSC Configurtion file <ResourceName>.config.ps1 (e.g. MSFT_xNeworking.config.ps1) from integration_config_template.ps1 file. .NOTES Code in HEADER, FOOTER and DEFAULT TEST regions are standard and may be moved into DSCResource.Tools in Future and therefore should not be altered if possible. #> $script:DSCModuleName = 'BizTalkServer' $script:DSCResourceName = 'MSFT_BizTalkServerHostInstance' #region HEADER # Integration Test Template Version: 1.1.1 [String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) } Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force $TestEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:DSCModuleName ` -DSCResourceName $script:DSCResourceName ` -TestType Integration #endregion # TODO: Other Init Code Goes Here... # Using try/finally to always cleanup. try { #region Integration Tests $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" . $configFile Describe "$($script:DSCResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile and apply the MOF without throwing' { { $configurationdata = @{ AllNodes = @( @{ NodeName = 'localhost' PSDscAllowPlainTextPassword = $true PSDscAllowDomainUser = $true } ) } & "$($script:DSCResourceName)_Config" -OutputPath $TestEnvironment.WorkingFolder -ConfigurationData $configurationdata Start-DscConfiguration -Path $TestEnvironment.WorkingFolder ` -ComputerName localhost -Wait -Verbose -Force } | Should not throw } It 'Should be able to call Get-DscConfiguration without throwing' { { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw } #endregion It 'Should have set the resource and all the parameters should match' { } } #endregion } finally { #region FOOTER $query = "SELECT * FROM MSBTS_HostInstance WHERE HostName='TestBizTalkServerApplication'" $instance = Get-CimInstance -Query $query -Namespace 'ROOT\MicrosoftBizTalkServer' if($null -ne $instance) { Invoke-CimMethod -InputObject $instance -MethodName Uninstall } $query = "SELECT * FROM MSBTS_HostSetting WHERE Name='TestBizTalkServerApplication'" $instance = Get-CimInstance -Query $query -Namespace 'ROOT\MicrosoftBizTalkServer' if($null -ne $instance) { Remove-CimInstance -InputObject $instance } }
PowerShellCorpus/PowerShellGallery/BizTalkServer/0.1.1.4/Tests/Integration/MSFT_BizTalkServerHost.config.ps1
MSFT_BizTalkServerHost.config.ps1
<# .Synopsis DSC Configuration Template for DSC Resource Integration tests. .DESCRIPTION To Use: 1. Copy to \Tests\Integration\ folder and rename <ResourceName>.config.ps1 (e.g. MSFT_xFirewall.config.ps1) 2. Customize TODO sections. .NOTES #> # Integration Test Config Template Version: 1.0.0 configuration MSFT_BizTalkServerHost_config { Import-DscResource -ModuleName 'BizTalkServer' node localhost { BizTalkServerHost TestBizTalkServerApplication { Name = 'TestBizTalkServerApplication' Ensure = 'Present' Is32Bit = $false Trusted = $true Tracking = $true Type = 'InProcess' Default = $false WindowsGroup = 'BizTalk Application Users' } } }
PowerShellCorpus/PowerShellGallery/PrtgAPI/0.6.9/PrtgAPI.GoPrtg.ps1
PrtgAPI.GoPrtg.ps1
function Get-GoPrtgServer { [CmdletBinding()] param ( [Parameter(Mandatory = $false, Position = 0)] [string] $Server ) if(Get-Command -Name __goPrtgGetServers -ErrorAction SilentlyContinue) { $serversText = @(__goPrtgGetServers)|foreach { "`"[ ]`",$_" } $servers = $serversText | ConvertFrom-Csv -Header "[!]","Server","Alias","UserName","PassHash" $client = Get-PrtgClient foreach($s in $servers) { if($s.Alias -eq "") { $s.Alias = $null } if($s.Server -eq $client.Server -and $s.UserName -eq $client.UserName) { $s."[!]" = "[*]" } } if($Server) { $servers = @($servers | ForEach-Object { if($_.Server -like $Server) { $_ } else { if($_.Alias -eq $Server) { $_ } } }) } $resp = $servers | Select-Object @{name="[!]";expression={$_."[!]"}},Server,Alias,UserName return $resp $response = @() foreach($server in $servers) { $username = $server.UserName $alias = $servers.Alias $obj = New-Object PSObject $obj | Add-Member NoteProperty Server $server.Server $obj | Add-Member NoteProperty Alias $alias $obj | Add-Member NoteProperty UserName $username $response += $obj } return $response } else { Write-ColorOutput "`nGoPrtg is not installed. Run Install-GoPrtgServer first to install a GoPrtg server.`n" -ForegroundColor Red } } function Connect-GoPrtgServer { [CmdletBinding()] param ( [Parameter(Mandatory = $false, Position = 0)] [string] $Server ) if(Get-Command __goPrtgGetServers -ErrorAction SilentlyContinue) { $servers = @(GetServers) if(!$Server) { $connectTo = $servers | Select-Object -First 1 ConnectToGoPrtgServer $connectTo } else { $matches = @($servers | Where-Object {$_.Server -like $Server -or $_.Alias -eq $Server}) if($matches.Count -eq 1) { ConnectToGoPrtgServer $matches } elseif($matches.Count -gt 1) { Write-ColorOutput "`nAmbiguous server specified. The following servers matched the specified server name or alias" -ForegroundColor Red Get-GoPrtgServer | Where-Object {$_.Server -like $Server -or $_.Alias -eq $Server} } else { Write-ColorOutput "`nCould not find server that matches name or alias '$Server'`n" -ForegroundColor Red } } } else { Write-ColorOutput "`nNo GoPrtg servers are installed. Please install a server first using Install-GoPrtgServer`n" -ForegroundColor Red } } function ConnectToGoPrtgServer($server) { $client = Get-PrtgClient if($server.Server -eq $client.Server -and $server.UserName -eq $client.UserName) { Write-ColorOutput "`nAlready connected to $($server.Server) as $($server.UserName)`n" -ForegroundColor Yellow } else { $credential = New-Object System.Management.Automation.PSCredential -ArgumentList $server.UserName, (ConvertTo-SecureString $server.PassHash) Connect-PrtgServer $server.Server $credential -PassHash -Force Write-ColorOutput "`nConnected to $($server.Server) as $($server.UserName)`n" -ForegroundColor Green } } function Set-GoPrtgAlias { [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Scope="Function")] [CmdletBinding()] param ( [Parameter(Mandatory = $false, Position = 0)] [string] $Alias ) if(!(Test-Path $Profile)) { throw "No GoPrtg servers are installed. To install a GoPrtg server, run Install-GoPrtgServer." } $contents = Get-Content $Profile $functionStart = GetGoPrtgStart $contents $functionEnd = GetGoPrtgEnd $contents $functionStart $functionExists = Get-Command __goPrtgGetServers -ErrorAction SilentlyContinue ValidateGoPrtgBlock $functionStart $functionEnd $functionExists if($functionExists) { if(!(Get-PrtgClient)) { throw "You are not connected to a PRTG Server. Please connect first using GoPrtg [<server>]." } $client = Get-PrtgClient $servers = @(GetServers) if($servers | Where-Object Alias -EQ $Alias) { throw "Cannot set alias for server '$($client.Server)': a record with alias '$Alias' already exists. For more information see Get-GoPrtgServer." } #todo: when we update the aliases in the file, we need to also update them in memory!! is that even happening? $targetServer = @($servers | Where-Object {$_.Server -eq $client.Server -and $_.UserName -eq $client.UserName }) if($targetServer.Count -eq 0) { throw "Server '$($client.Server)' is not a valid GoPrtg server. To install this server, run Install-GoPrtgServer [<alias>]" } elseif($targetServer.Count -eq 1) { if(!$Alias -and $targetServer.Alias -ne $null) { if(($servers | Where-Object {$_.Server -eq $client.Server}).Count -gt 1) { throw "Cannot remove alias of server: multiple entries for server '$($client.Server)' are stored within GoPrtg. To remove this alias uninstall all other entries for this server. For more information see Get-GoPrtgServer." } } SetPrtgGoAliasInternal $contents $targetServer $functionStart $functionEnd $Alias } elseif($targetServer.Count -gt 1) { throw "A critical error has occurred: more than one server exists with the same server and username. Please remove the duplicate from your $Profile manually." } } else { throw "GoPrtg is not installed. Run Install-GoPrtgServer <alias> to install a server with the specified alias." } } function SetPrtgGoAliasInternal($contents, $server, $functionStart, $functionEnd, $Alias) { $new = @() for($i = $functionStart + 3; $i -le $functionEnd -3; $i++) { $line = $contents[$i] $compare = $null if($null -ne $server.Alias -and $server.Alias -ne "") { $compare = " `"```````"$($server.Server)```````",```````"$($server.Alias)```````",```````"$($server.UserName)```````",```````"$($server.PassHash)```````"`"*" } else { $compare = " `"```````"$($server.Server)```````",,```````"$($server.UserName)```````",```````"$($server.PassHash)```````"`"*" } if($line -like $compare) { $newLine = $null if($null -ne $Alias -and $Alias -ne "") { $newLine = " `"```"$($server.Server)```",```"$Alias```",```"$($server.UserName)```",```"$($server.PassHash)```"`"" } else { $newLine = " `"```"$($server.Server)```",,```"$($server.UserName)```",```"$($server.PassHash)```"`"" } if($line.EndsWith(",")) { $newLine += "," } $new += $newLine } else { $new += $line } } $final = AddGoPrtgFunctionHeaderAndFooter $contents $new $functionStart $functionEnd UpdateGoPrtgFunctionBody $final $contents $functionStart $functionEnd .([ScriptBlock]::Create(($final -replace "function ","function global:"))) } #region Install-GoPrtgServer function Install-GoPrtgServer { [CmdletBinding()] param ( [Parameter(Mandatory = $false, Position = 0)] [string] $Alias ) if(!(Get-PrtgClient)) { throw "You are not connected to a PRTG Server. Please connect first using Connect-PrtgServer." } $new = $false if(!(Test-Path $Profile)) { New-Item $Profile -Type File -Force $new = $true } #todo: what is the force parameter meant to do? overwrite? if so we need to update some of the existing exception messages $newContents = GetNewContents $Alias $profileContent = GetProfileContents $newContents if($new) { Add-Content $Profile $profileContent } else { Set-Content $Profile $profileContent } .([ScriptBlock]::Create(($newContents.Func -replace "function ","function global:"))) } function GetNewContents($alias) { $contents = Get-Content $Profile $functionStart = GetGoPrtgStart $contents $functionEnd = GetGoPrtgEnd $contents $functionStart $functionExists = Get-Command __goPrtgGetServers -ErrorAction SilentlyContinue ValidateGoPrtgBlock $functionStart $functionEnd $functionExists # If the function didn't exist but the header and footer did, an exception would have been thrown above. # We can infer then that if we've reached this stage and the function doesn't exist, the header and footer don't exist either if($functionExists) { $servers = @(GetServers) CheckServerAgainstExistingRecords $servers $alias $pre = GetPre $contents $functionStart $post = GetPost $contents $functionEnd $new = GetNew $servers $alias $obj = ContentsObj $obj.Pre = $pre $obj.Func = $new $obj.Post = $post return $obj } else { $new = GetNew $null $alias $obj = ContentsObj $obj.Pre = $contents $obj.Func = $new $obj.Post = $null return $obj } } function ValidateGoPrtgBlock { [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSPossibleIncorrectComparisonWithNull", "", Scope="Function")] param($functionStart, $functionEnd, $functionExists) if($functionStart -eq $null -and $functionEnd -ne $null) { throw "GoPrtg Servers start line '########################### Start GoPrtg Servers ###########################' has been removed from PowerShell profile. Please reinstate line or remove all lines pertaining to GoPrtg from your profile." } if($functionStart -ne $null -and $functionEnd -eq $null) { throw "GoPrtg Servers end line '############################ End GoPrtg Servers ############################' has been removed from PowerShell profile. Please reinstate line or remove all lines pertaining to GoPrtg from your profile." } if($functionStart -ne $null -and $functionEnd -ne $null) { if(!$functionExists) { throw "GoPrtg header and footer are present in PowerShell profile, however __goPrtgGetServers function was not loaded into the current session. Please verify the function has not been corrupted or remove the GoPrtg header and footer and re-run Install-GoPrtgServer." } } } function GetServers { $servers = __goPrtgGetServers | ConvertFrom-Csv -Header "Server","Alias","UserName","PassHash" foreach($server in $servers) { if($server.Alias -eq "") { $server.Alias = $null } } return $servers } function GetProfileContents($newContents) { $funcBody = "" if($null -ne $newContents.Pre) { $funcBody += [string]::Join("`r`n", $newContents.Pre) + "`r`n" } # Due to the way Powershell's Command Discovery works, PowerShell will detect match the Get-GoPrtg alias to the command GoPrtg # before detecting GoPrtg is in fact a valid alias all by itself. By forcing the module to import, PowerShell will correctly # identify that GoPrtg is the intended command. $funcBody += "########################### Start GoPrtg Servers ###########################`r`n`r`n" + [string]::Join("`r`n", $newContents.Func) + "`r`n`r`n############################ End GoPrtg Servers ############################" if($null -ne $newContents.Post) { $funcBody += "`r`n" + [string]::Join("`r`n", $newContents.Post) } return $funcBody } function CheckServerAgainstExistingRecords($servers, $alias) { $client = Get-PrtgClient if($servers | Where-Object {$_.Server -eq $client.Server }) { $record = $servers | Where-Object {$_.Server -eq $client.Server } | Select-Object -first 1 if($null -ne $record.Alias) { if($record.UserName -eq $client.UserName) { throw "Cannot add server '$($client.Server)': a record for user '$($client.UserName)' already exists. To update the alias of this record use Set-GoPrtgAlias. To reinstall this record, first uninstall with Uninstall-GoPrtgServer and then re-run Install-GoPrtgServer." } if(!$alias) { throw "Cannot add server '$($client.Server)': an alias must be specified to differentiate this connection from an existing connection with the same server address." } } else { if($record.UserName -eq $client.UserName) { throw "Cannot add server '$($client.Server)': a record for user '$($client.UserName)' already exists." } throw "Cannot add server '$($client.Server)': a record for server already exists without an alias. Please update the alias of this record with Set-GoPrtgAlias and try again." } } elseif($servers | Where-Object {$_.Alias -eq $alias}) { throw "Cannot add server '$($client.Server)' with alias '$alias': a record for this alias already exists. For more information see 'Get-GoPrtgServer $alias'" } } function GetGoPrtgStart($contents) { for($i = 0; $i -lt $contents.Length; $i++) { if($contents[$i] -eq "########################### Start GoPrtg Servers ###########################") { return $i } } return $null } function GetGoPrtgEnd($contents) { if($functionStart -ne -1) { for($i = $functionStart + 1; $i -lt $contents.Length; $i++) { if($contents[$i] -eq "############################ End GoPrtg Servers ############################") { return $i } } } return $null } function GetPre($contents, $functionStart) { $index = 0 $pre = $contents | ForEach-Object { if($index -lt $functionStart) { $_ } $index++ } return $pre } function GetPost($contents, $functionEnd) { $index = 0 $post = $contents | ForEach-Object { if($index -gt $functionEnd) { return $_ } $index++ } return $post } function GetNew { [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Scope="Function")] param($servers, $alias) $client = Get-PrtgClient $secureString = ConvertTo-SecureString $client.PassHash -AsPlainText -Force $encryptedString = ConvertFrom-SecureString $secureString #$encryptedString = $client.PassHash if(!$servers) { $servers = @() } $newRecord = SerializeRecord $client.Server $alias $client.UserName $encryptedString $newRecord = $newRecord -replace "`"```"","`"" -replace "```"`"","`"" -replace "```"","`"" $r = $newRecord | ConvertFrom-Csv -Header "Server","Alias","UserName","PassHash" if($r.Alias -eq "") { $r.Alias = $null } <#$obj = New-Object PSObject $obj | Add-Member NoteProperty Server $client.Server $obj | Add-Member NoteProperty Alias $alias $obj | Add-Member NoteProperty UserName $client.UserName $obj | Add-Member NoteProperty PassHash $encryptedString#> $servers += $r $newContents = @() $newContents += "function __goPrtgGetServers {@(" $index = 0 $count = $servers.Count foreach($s in $servers) { $toAdd = SerializeRecord $s.Server $s.Alias $s.UserName $s.PassHash if($count -gt 1 -and ($index -lt $count - 1)) { $toAdd += "," } $newContents += $toAdd $index++ } $newContents += ")}" return $newContents } function SerializeRecord($server, $alias, $username, $passhash) { $record = $null if($alias) { $record = " `"```"$server```",```"$alias```",```"$username```",```"$passhash```"`"" } else { $record = " `"```"$server```",,```"$username```",```"$passhash```"`"" } return $record } function ContentsObj { $obj = @{ "Pre" = @(); "Func" = @(); "Post" = @() } return $obj } #endregion Install-GoPrtgServer #region Uninstall-GoPrtgServer function Uninstall-GoPrtgServer([string]$Server, [switch]$Force) { if(!(Test-Path $Profile)) { throw "No GoPrtg servers are installed. To install a GoPrtg server, run Install-GoPrtgServer." } $contents = Get-Content $Profile $functionStart = GetGoPrtgStart $contents $functionEnd = GetGoPrtgEnd $contents $functionStart $functionExists = Get-Command __goPrtgGetServers -ErrorAction SilentlyContinue ValidateGoPrtgBlock $functionStart $functionEnd $functionExists if($functionExists) { $servers = @(GetServers) $Server = SetServerWildcardIfMissing $Server $servers $Force $matches = @(GetMatches $Server $servers) $filtered = GetFiltered $contents $matches $functionStart $functionEnd if($filtered) { $filtered = AddGoPrtgFunctionHeaderAndFooter $contents $filtered $functionStart $functionEnd } UpdateGoPrtgFunctionBody $filtered $contents $functionStart $functionEnd if($null -ne $filtered) { .([ScriptBlock]::Create(($filtered -replace "function ","function global:"))) } else { Remove-Item Function:\__goPrtgGetServers } } else { throw "No GoPrtg servers are installed. To install a GoPrtg server, run Install-GoPrtgServer." } } function SetServerWildcardIfMissing($server, $servers, $force) { if($force) { $server = "*" } else { if(!$server) { if($servers.Count -gt 1) { throw "Cannot remove servers; server name or alias must be specified when multiple entries exist. To remove all servers, specify -Force" } else { $server = "*" } } } return $server } function GetMatches($server, $servers) { $matches = @() foreach($s in $servers) { if($s.Server -like $server) { $matches += $s } else { if($null -ne $s.Alias) { if($s.Alias -like $server) # the alias { $matches += $s } } } } if(!$matches) { throw "'$server' is not a valid server name or alias. To view all saved servers, run Get-GoPrtgServer" } return $matches } function GetFiltered($contents, $matches, $functionStart, $functionEnd) { $filtered = @() for($i = $functionStart + 3; $i -le $functionEnd - 3; $i++) { $line = $contents[$i] $include = $true foreach($s in $matches) { $toRemove = $null if($null -ne $s.Alias) { $toRemove = " `"```````"$($s.Server)```````",```````"$($s.Alias)```````",```````"$($s.UserName)```````",```````"$($s.PassHash)```````"`"*" #do we need twice as many backticks? } else { $toRemove = " `"```````"$($s.Server)```````",,```````"$($s.UserName)```````",```````"$($s.PassHash)```````"`"*" } if($line -like $toRemove) { $include = $false break } } if($include) { $filtered += $line } } if($filtered) { $filtered = AdjustFilterRecordDelimiters $contents $filtered $functionStart $functionEnd } return $filtered } function AdjustFilterRecordDelimiters($contents, $filtered, $functionStart, $functionEnd) { for($i = 0; $i -lt $filtered.Count; $i++) { if($i -lt $filtered.Count - 1) { if(!$filtered[$i].EndsWith(",")) { $filtered[$i] = $filtered[$i] + "," } } else { if($filtered[$i].EndsWith(",")) { $filtered[$i] = $filtered[$i].Substring(0, $filtered[$i].Length - 1) } } } return $filtered } function AddGoPrtgHeaderAndFooter($contents, $funcBody, $functionStart, $functionEnd) { $formatted = @() $formatted += $contents[$functionStart] $formatted += $contents[$functionStart + 1] $formatted += $funcBody $formatted += $contents[$functionEnd - 1] $formatted += $contents[$functionEnd] return $formatted } function AddGoPrtgFunctionHeaderAndFooter($contents, $funcBody, $functionStart, $functionEnd) { $formatted = @() $formatted += $contents[$functionStart + 2] $formatted += $funcBody $formatted += $contents[$functionEnd - 2] return $formatted } function UpdateGoPrtgFunctionBody($funcBody, $contents, $functionStart, $functionEnd) { $pre = GetPre $contents $functionStart $post = GetPost $contents $functionEnd $newContent = @() $newContent += $pre if($null -ne $funcBody) { $funcBody = AddGoPrtgHeaderAndFooter $contents $funcBody $functionStart $functionEnd $newContent += $funcBody } $newContent += $post $str = [string]::Join("`r`n", $newContent) if($str -eq "") { Set-Content $Profile $str -NoNewline } else { Set-Content $Profile $str } } #endregion function Write-ColorOutput($Object, $ForegroundColor) { $initialColor = $Host.UI.RawUI.ForegroundColor if($initialColor -ne -1) { $Host.UI.RawUI.ForegroundColor = $ForegroundColor } $Object | Write-Output if($initialColor -ne -1) { $Host.UI.RawUI.ForegroundColor = $initialColor } #need to test piping something with a header } #todo: all of these tests should test extracting the passhash and confirming it decrypts to the original value #todo: run invoke-scriptanalyzer when finished #todo: make the passhash encrypted again, change the should be's to should belike's #todo: if you remove the last server, the second last server should remove its semicolon #make nuget.org and powershellgallery nuspecs able to show whats new by querying appveyor #push notes #maybe we should consider using the password vault? #https://www.powershellgallery.com/packages/BetterCredentials/4.3/Content/BetterCredentials.psm1 #note: if we use the windows credential store, our module wont be cross platform compatible Export-ModuleMember -Function Install-GoPrtgServer,Uninstall-GoPrtgServer,Get-GoPrtgServer,Connect-GoPrtgServer,Set-GoPrtgAlias
PowerShellCorpus/PowerShellGallery/InvokeQuery/1.0.1/DebugSetup.ps1
DebugSetup.ps1
Write-Host "Importing module...." Import-Module .\InvokeQuery.dll Write-Host "Hello world" ## CREATE TABLE [dbo].[sometable]([id] [int] NOT NULL, [somestring] [nvarchar](255) NOT NULL, [someint] [int] NOT NULL, [somedate] [datetime2](7) NOT NULL, CONSTRAINT [PK_sometable] PRIMARY KEY CLUSTERED ([id] ASC)) ## $db = "test" $sql1 = "update table1 set someint = 4321 where pk = '1A9F96AE-54FA-40F9-9069-749F3ACF0CEF';" $sql2 = "UPDATE table1 set someint = 1234 where pk = '89F21B61-891B-42CD-9BED-84BA4B7EB7D0';" $callback = { param ($sqlQuery, $input) Write-Host $sqlQuery.Sql Write-Host "blahb lah blah $input." ##throw "AAAAAAHHHHHHHHHHHGGGGGGGGGGGG!!!!!!!!!!!!!" } $q1 = New-SqlQuery -Sql $sql1 -Callback $callback -CUD $q2 = New-SqlQuery -Sql $sql2 -Callback $callback -CUD $count = ($q1, $q2) | Invoke-SqlServerQuery -Database $db -Verbose Write-Host "Count $count." #$sql = "select * from table1 where somestring = ' update insert delete UPDATE INSERT DELETE ';" #$result = $sql | Invoke-SqlServerQuery -Database $db -Verbose #$result | ft #$query = "select * from sometable;" #$query | Invoke-SqlServerQuery -Database "test" -Verbose ##$params = @{"id"=7; "str"="hello"; "inte"=44; "dt"=(Get-Date); "blah"="blah"} #156..160 | %{ # [pscustomobject] @{ # "Sql" = "insert into sometable values (@id, @str, @inte, @dt);"; # "Parameters" = @{ "id"=$_; "str"="hi"; "inte"=$_ + 99; "dt"=$(Get-Date); } # } #} | Invoke-SqlServerQuery -Database "test" -CUD -Verbose #171..175 | %{ # New-SqlQuery -Sql "insert into sometable values (@id, @str, @inte, @dt);" -ExpectedRowCount 0 -Parameters @{ "id"=$_; "str"="hi"; "inte"=$_ + 99; "dt"=$(Get-Date); } -CUD # } | Invoke-SqlServerQuery -Database "test" -Verbose ##$query = "insert into sometable values (@id, @str, @inte, @dt);" ##$query | Invoke-SqlServerQuery -Database "test" -Parameters $params -NonQuery -Verbose
PowerShellCorpus/PowerShellGallery/Log/1.0.2/Public/Add-Log.ps1
Add-Log.ps1
function Add-Log { <# .NOTES Title: Add-Log.ps1 Author: Curtis Jones Date: March 24th, 2017 Version: 1.0.1 Requirements: Powershell 3.0 .SYNOPSIS Provides code execution string logging into $env:LOCALAPPDATA\PowerShellLogging directory along with the ability to output to all valid PowerShell streams simultaneously. .DESCRIPTION Add-Log provides a simple but effective way to simultaneously log all desired information to a standardized logging location within $env:LOCALAPPDATA\PowerShellLogging while also allowing simultaneous output to all valid PowerShell streams. This function works in conjunction with the Set-LogFile function to generate and maintain a healthy log file structure. This function is all that needs to be called to automatically generate a valid logging file and start using it. .PARAMETER Message The message that will be logged to the local log file and also output to PowerShell stream if the Out switch is used. .PARAMETER Type Used to indicate the type of log message and also used to correlate the type of stream to be utilized if the Out switch is used. .PARAMETER Out Used to output the log message to the corresponding message stream and also output to console. .PARAMETER LogFileSizeThreshold Provide a valid size for a log file threshold such as 1GB, 500MB, 1024KB, etc. .EXAMPLE Add-Log -Message "The reactor core has reached critical mass" -Type Warning -Out The above example would write the message string to the log file indicated by the path within the script scope $logFile variable generated by Set-LogFile and will also pass the message into the warning stream and output to the console. #> [CmdletBinding()] [Alias("Log")] param ( [parameter(Mandatory=$true,Position=0,HelpMessage="The message that will be logged and also output to PowerShell stream if the Out switch is used.")] [string]$Message, [parameter(Mandatory=$true,Position=1,HelpMessage="Used to indicate the type of log message and also used to correlate the type of stream to be utilized if the Out switch is used.")] [ValidateSet("Normal","Error","Warning","Debug","Verbose","Information")] [string]$Type, [parameter(Mandatory=$false,Position=2,HelpMessage="Use switch to output the log message to the corresponding stream and also output it to the console.")] [switch]$Out, [parameter(Mandatory=$false,Position=3,HelpMessage="Provide a valid size for a log file threshold such as 1GB, 500MB, 1024KB, etc. The default parameter value is 100MB.")] [int]$LogFileSizeThreshold=100MB ) begin { #If no logFile variable is present in the current PSSession, the logFile path does not exist, or the logFile variable file name does not equal the current invocation execution file name without extension the Set-LogFile function will be called to generate a logFile variable pointing to a new or existing log file based on the name of the invocation script. if((-not $logFile) -or (-not [System.IO.File]::Exists($logFile)) -or ([System.IO.Path]::GetFileNameWithoutExtension($logFile) -ne [System.IO.Path]::GetFileNameWithoutExtension($MyInvocation.PSCommandPath))) { try { $script:logFile = Set-LogFile -LogFileName $MyInvocation.PSCommandPath -ShowLocation -ErrorAction Stop } catch { throw } } } process { if(Test-Path $logfile) { #A string is constructed including the datetime, current PowerShell process ID, executing windows username, log type param, and message string param. The full string is output to the logFile variable with the append switch utilized as to not overwrite any existing entries. "[$(Get-Date -format 'G') | $($pid) | $($env:username) | $($Type.ToUpper())] $message" | Out-File -FilePath $logFile -Append #If the out switch is called the following block will be entered. The type param input will determine the switch block to enter which will call the correlating stream cmdlet to add the message string to the corresponding stream but also output it to the console. if($out) { switch ($type) { Normal { Write-Output $message } Error { Write-Error -Message $message } Warning { Write-Warning -Message $message } Debug { Write-Debug -Message $message -Debug } Verbose { Write-Verbose -Message $message -Verbose } Information { if(($PSVersionTable.PSVersion.Major) -ge 5) { Write-Information -MessageData $message -InformationAction Continue } } } } #An attempt is made to set a log variable and an evaluation is made to determine if the current log file size divided by the log file threshold is greater than or equal to one. If the log file quotient is greater than one the following block if statement will be entered and an attempt will be made to rename the current log file to scriptname_date.old convention and create a new log file and set a script level logFile variable. The renaming event will be logged to the new log file that is created. $log = Get-Item $logFile if(($log.Length / $logFileSizeThreshold) -ge '1') { try { Rename-Item -Path $log.FullName -NewName "$($log.BaseName)_$(Get-Date -Format ddMMyyThhmmss).old" -ErrorAction Stop $script:logFile = Set-LogFile -LogFileName $MyInvocation.PSCommandPath -ErrorAction Stop "Log file $($log.Name) was found to be at $($log.length) Bytes size which is larger than the allowed size threshold of $($logFileSizeThreshold) Bytes, prior log file has been renamed to $($log.BaseName)_$(Get-Date -Format ddMMyyThhmmss).old." | Out-File -FilePath $logFile -Append } catch { throw } } } else { break } } end { } }
PowerShellCorpus/PowerShellGallery/Log/1.0.2/Public/Set-LogFile.ps1
Set-LogFile.ps1
function Set-LogFile { <# .NOTES Title: Set-LogFile.ps1 Author: Curtis Jones Date: March 24th, 2017 Version: 1.0.0 Requirements: Powershell 3.0 .SYNOPSIS Provides log file generation in the $env:LOCALAPPDATA\PowerShellLogging folder based on input from the Add-Log function. .DESCRIPTION Set-LogFile provides an easy and effective way to create a new log file if necessary in the $env:LOCALAPPDATA\PowerShellLogging folder. If necessary the path and the file will be created and a file path string will be returned by the function for use by the Add-Log function. If the ShowLocation switch param is used the MessageBox show method will be used to display the location of the created file. .PARAMETER LogFileName Provide a simple name with no spaces such as < ScriptName > .PARAMETER ShowLocation Use switch to utilize the Forms.MessageBox method to display the log file name and location. .EXAMPLE Set-LogFile -LogFileName TestLogName -ShowLocation The example above will create the following log file/location, $env:LOCALAPPDATA\PowerShellLogging\TestLogName\TestLogName.log. The log file location will be displayed using the MessageBox show method. #> [CmdletBinding()] [OutputType([string])] param ( [parameter(Mandatory=$true,HelpMessage="Provide a simple name with no spaces such as < ScriptName >.")] [string]$LogFileName, [parameter(Mandatory=$false,HelpMessage="Use switch to utilize the Forms.MessageBox method to display the log file name and location.")] [switch]$ShowLocation ) process { #A logPath string variable is set utilizing an IO.Path method to combine the local AppData path, PowerShellLogging string, and the logFileName param after it's been sanitized of any extensions or invalid characters that may have been erroneously input to the function. $logPath = ([System.IO.Path]::Combine($env:LOCALAPPDATA,'PowerShellLogging',[System.IO.Path]::GetFileNameWithoutExtension($logFileName))) #If the logPath location does not exist the following block will be entered and the directory will be created. If creation fails a terminating error will be thrown. if(-not (Test-Path $logPath)) { try { New-Item -ItemType Directory -Path $logPath -ErrorAction Stop | Out-Null } catch { throw } } #A logFile string variable will be constructed utilzing the logPath string, sanitized logFileName param input, and all necessary delimiters and extensions. If the logFile file path does not exist it will be created by the try/catch. [string]$logFile = $logPath + '\' + $([System.IO.Path]::GetFileNameWithoutExtension($logFileName)) + ".log" if(-not (Test-Path $logFile)) { try { New-Item -ItemType File -Path $logFile -ErrorAction Stop | Out-Null } catch { throw } } #If the ShowLocation param is used and the executing invocation is running in UserInteractive mode the following block will be entered. The Win32 Forms assembly will be loaded to expose the MessageBox class and methods. The Show method is used to pop up a Windows forms box to indicate the log file location and the user must acknowledge this by clicking on the OK button within the message box dialog. if($ShowLocation -and ([Environment]::UserInteractive)) { Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.MessageBox]::Show("Please refer to the log file located at the following location.`r`n`n$($logFile)","Log File Setup") | Out-Null } } #The logFile file path string will be returned to the calling code. end { return $logFile } }
PowerShellCorpus/PowerShellGallery/coveralls/1.0.25/Coveralls.ps1
Coveralls.ps1
function Add-CoverageInfo { [CmdletBinding()] param ( [parameter(Position=1)] $CoverageResultSet, [parameter(Mandatory = $true,Position=2)] $Value ) foreach ($coverageResult in $CoverageResultSet) { $coverageResult | Add-Member -MemberType NoteProperty -Name CoverageResult -Value $Value } } function Merge-CoverageResult { [CmdletBinding()] param ( [parameter(Position=1)] $HitCommands, [parameter(Position=2)] $MissedCommands, [parameter(Mandatory = $true,Position=3)] $File ) # check what has been analyzed and provide context Add-CoverageInfo -CoverageResultSet $HitCommands -Value 1 Add-CoverageInfo -CoverageResultSet $MissedCommands -Value 0 # add both arrays for easier enumeration $allCommandsArray = @(); $allCommandsArray += $HitCommands $allCommandsArray += $MissedCommands return $allCommandsArray } function Get-CoverageArray { [CmdletBinding()] param ( [parameter(Mandatory = $true,Position=1)] $CoverageResultArray, [parameter(Mandatory = $true,Position=2)] $File ) # count the lines $lineCount = (Get-Content $File).Count $coverageArray = @() # loop the lines and math with the provided results for($line=1; $line -lt ($lineCount + 1); $line++){ $processedLine = $CoverageResultArray | Where-Object {$_.Line -eq $line} $coverageArray += if ($processedLine) { # make sure got the hit count correct (hate the indentation) $firstobject = $processedLine | Select-Object -First 1 if ($processedLine.count -gt 1 -and $firstobject.CoverageResult -eq 1) { $processedLine.count } else { $firstobject.CoverageResult } } else { $null } } return $coverageArray } function Format-FileCoverage { [CmdletBinding()] param ( [parameter(Mandatory = $true,Position=1)] $CoverageArray, [parameter(Mandatory = $true,Position=2)] $File, [parameter(Mandatory = $true,Position=3)] $RootFolder ) $fileHash = Get-FileHash $File -Algorithm MD5 $root = (Get-Item $RootFolder).FullName $fileName = (Get-Item $File).FullName.Replace($root, '').Replace('\','/') if ($fileName.StartsWith('/')) { $fileName = $fileName.Remove(0,1) } return New-Object -TypeName PSObject -Property @{ name = $fileName source_digest = $fileHash.Hash coverage = $CoverageArray } } function Get-CommandsForFile { [CmdletBinding()] param ( [parameter(Mandatory = $true,Position=1)] $Commands, [parameter(Mandatory = $true,Position=2)] $File ) $fullName = (Get-Item $File).FullName $matchedCommands = $Commands | Where-Object { $_.File -eq $fullName } return $matchedCommands } function Get-GitInfo { [CmdletBinding()] param( [string] $BranchName ) if (!$BranchName) { $BranchName = (git rev-parse --abbrev-ref HEAD) } return New-Object -TypeName PSObject -Property @{ head = New-Object -TypeName PSObject -Property @{ id = (git log --format="%H" HEAD -1) author_name = (git log --format="%an" HEAD -1) author_email = (git log --format="%ae" HEAD -1) committer_name = (git log --format="%cn" HEAD -1) committer_email = (git log --format="%ce" HEAD -1) message = (git log --format="%s" HEAD -1) } branch = $BranchName } } function Format-Coverage { [CmdletBinding()] param ( [parameter(Mandatory = $true, Position = 0, ParameterSetName = "PesterResults")] $PesterResults, [parameter(Mandatory = $true, Position = 1, ParameterSetName = "Include")] $Include, [parameter(Mandatory = $true,Position=2)] [string] $CoverallsApiToken, $BranchName, $RootFolder = $pwd ) $fileCoverageArray = @() if (!$pesterResults) { $pesterResults = Invoke-Pester -CodeCoverage $Include -Quiet -PassThru } if (!$pesterResults.CodeCoverage) { Write-Error 'Please provide pester results with code coverage using the -CodeCoverage parameter' return; } foreach ($file in $pesterResults.CodeCoverage.AnalyzedFiles) { $hitcommands = Get-CommandsForFile -Commands $pesterResults.CodeCoverage.HitCommands -File $file $missedCommands = Get-CommandsForFile -Commands $pesterResults.CodeCoverage.MissedCommands -File $file $coverageResult = Merge-CoverageResult -HitCommands $hitcommands -MissedCommands $missedCommands -File $file $coverageArray = Get-CoverageArray -CoverageResultArray $coverageResult -File $file $fileCoverageArray += (Format-FileCoverage -CoverageArray $coverageArray -File $file -RootFolder $RootFolder) } $git = Get-GitInfo -BranchName $BranchName return New-Object -TypeName PSObject -Property @{ repo_token = $CoverallsApiToken commit_sha = (git log --format="%H" HEAD -1) git = $git service_name = 'appveyor' source_files = $fileCoverageArray } } function Publish-Coverage { [CmdletBinding()] param ( [parameter(Mandatory = $true,Position=1)] $Coverage ) Add-Type -AssemblyName System.Net.Http $stringContent = New-Object System.Net.Http.StringContent (ConvertTo-Json $Coverage -Depth 3) $httpClient = New-Object System.Net.Http.Httpclient $formdata = New-Object System.Net.Http.MultipartFormDataContent $formData.Add($stringContent, "json_file", "coverage.json") $result = $httpClient.PostAsync('https://coveralls.io/api/v1/jobs', $formData).Result; $content = $result.Content.ReadAsStringAsync() $coverageResult = ConvertFrom-Json $content.Result return $coverageResult.url } function Get-CoveragePercentage { [CmdletBinding()] param ( [parameter(Mandatory = $true,Position=1)] $RepositoryLink ) try { $response = Invoke-WebRequest -UseBasicParsing "$RepositoryLink.json" $coverageInfo = ConvertFrom-Json $response.Content return $coverageInfo.covered_percent } catch { Write-Error 'We could not complete your request.' } }
PowerShellCorpus/PowerShellGallery/coveralls/1.0.25/Coveralls.Tests.ps1
Coveralls.Tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") . "$here\$sut" Describe "Get-CoveragePercentage" { Context "Providing a correct return" { BeforeAll { $content = "{""created_at"":""2017-03-16T12:37:17Z"",""url"":null,""commit_message"":""Add fake data to CA_KEY when it's not present"",""branch"":""master"",""committer_name"":""Jan De Dobbeleer"",""committer_email"":""jan@gmail.com"",""commit_sha"":""ba5947862030d86208d0181189c160df04e5c309"",""repo_name"":""JanJoris/coveralls"",""badge_url"":""https://s3.amazonaws.com/assets.coveralls.io/badges/coveralls_13.svg"",""coverage_change"":0.0,""covered_percent"":%percentage%}" } It "has a coverage percentage of 13" { Mock Invoke-WebRequest { return @{ Content = $content.Replace('%percentage%', '13') }} Get-CoveragePercentage -RepositoryLink coveralls | Should Be 13 } It "has a coverage percentage of 28" { Mock Invoke-WebRequest { return @{ Content = $content.Replace('%percentage%', '28') }} Get-CoveragePercentage -RepositoryLink coveralls | Should Be 28 } } Context "Providing an exception return" { It "throws an error when providing bogus info" { { Get-CoveragePercentage -RepositoryLink coveralls -ErrorAction Stop } | Should Throw } It "throws an error when providing a non-existing repository" { { Get-CoveragePercentage -RepositoryLink https://coveralls.io/coveralls/coveralls -ErrorAction Stop } | Should Throw } } Context "Providing crappy data" { It "has no content object to parse" { Mock Invoke-WebRequest { return @{ NotContent = "I am so crappy" }} { Get-CoveragePercentage -RepositoryLink coveralls -ErrorAction Stop } | Should Throw } } } Describe "Get-CommandsForFile" { Context "Receiving proper input" { It "has 2 commands that match the file" { $commands = @( @{ File = "file.ps1" Line = 1 }, @{ File = "file.ps1" Line = 2 }, @{ File = "file2.ps1" Line = 3 } ) Mock Get-Item { return @{ FullName = 'file.ps1' }} $result = Get-CommandsForFile -Commands $commands -File 'file.ps1' $result.Count | Should be 2 } It "has 0 commands that match the file" { $commands = @( @{ File = "file2.ps1" Line = 1 }, @{ File = "file2.ps1" Line = 2 } ) Mock Get-Item { return @{ FullName = 'file.ps1' }} $result = Get-CommandsForFile -Commands $commands -File 'file.ps1' $result.Count | Should be 0 } } Context "Receiving crappy input" { It "should not output any match" { $commands = @{ Balony = "garbage" Ohn0 = 1324343 } Mock Get-Item { return @{ FullName = 'file.ps1' }} $result = Get-CommandsForFile -Commands $commands -File 'file.ps1' $result.Count | Should be 0 } } } Describe "Format-FileCoverage" { Context "Receiving proper input" { It "outputs the expected information" { $expected = New-Object -TypeName PSObject -Property @{ name = 'file.ps1' source_digest = '123456789' coverage = 'Test' } Mock Get-FileHash { return @{ Hash = '123456789' }} Mock Get-Item -ParameterFilter { $Path -eq 'RootFolder' } { @{ FullName = 'root' } } Mock Get-Item -ParameterFilter { $Path -eq 'File' } { @{ FullName = 'root\file.ps1' } } $result = Format-FileCoverage -CoverageArray 'Test' -File 'File' -RootFolder 'RootFolder' $result | Should MatchExactly $expected } It "handles the paths without an issue" { $expected = New-Object -TypeName PSObject -Property @{ name = 'file.ps1' source_digest = '123456789' coverage = 'Test' } Mock Get-FileHash { return @{ Hash = '123456789' }} Mock Get-Item -ParameterFilter { $Path -eq 'RootFolder' } { @{ FullName = 'root' } } Mock Get-Item -ParameterFilter { $Path -eq 'File' } { @{ FullName = 'file.ps1' } } $result = Format-FileCoverage -CoverageArray 'Test' -File 'File' -RootFolder 'RootFolder' $result | Should MatchExactly $expected } } }
PowerShellCorpus/PowerShellGallery/xOSSEC/1.0.2/Example/Sample_xOSSEC.ps1
Sample_xOSSEC.ps1
# Sample configuration using xOSSEC # Vasken Houdoverdov # # Each of the calls to Sample_InstallxOSSEC below will generate a MOF file which can then be fed into Start-DscConfiguration # # Sample_InstallxOSSEC -VersionNumber "2.8" -LocalPath "C:\Windows\DtlDownloads\ossec-agent-win32-2.8.exe" # Sample_InstallxOSSEC -VersionNumber "2.7.1" -LocalPath "C:\Windows\DtlDownloads\ossec-agent-win32-2.7.1.exe" # # Note that the silent installation for OSSEC 2.7.1 does not automatically place shortcuts to the Manage Agent utility in the start menu. Configuration Sample_InstallxOSSEC { param ( [Parameter(Mandatory)] $VersionNumber, [Parameter(Mandatory)] $LocalPath ) Import-DscResource -module xOSSEC VH_xOSSEC ossec { VersionNumber = $VersionNumber LocalPath = $LocalPath } }
PowerShellCorpus/PowerShellGallery/PS.HealthChecks/1.0.19/Public/Connect-HealthCheck.ps1
Connect-HealthCheck.ps1
function Connect-HealthCheck { <# .SYNOPSIS The Connect-HealthCheck cmdlet store the API key for the HealthCheck module cmdlets. Connect-HealthCheck will only store the API key, no validation is done. .DESCRIPTION The Connect-B2Cloud cmdlet is used to store the API key for the HealthCheck cmdlets. The API key can be obtained from your HealthCheck account page. .EXAMPLE Connect-HealthCheck The above cmdlet will prompt for the API key and save the API key for use in the other HealthCheck modules. .EXAMPLE PS C:\>Connect-B2Cloud -ApiKey YOUR_API_KEY The above cmdlet will take the given API key and save the API key for use in the other HealthCheck modules. .INPUTS System.String This cmdlet takes the API key as a string. .OUTPUTS None .NOTES Connect-HealthCheck will only store the API key, no validation is done. .LINK https://healthchecks.io/docs/ .ROLE PS.HealthChecks .FUNCTIONALITY PS.HealthChecks #> [CmdletBinding(SupportsShouldProcess=$false, PositionalBinding)] [Alias()] [OutputType()] Param ( # The API key to access the HealthCheck account. [Parameter(Mandatory)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [Alias('Key')] [String]$ApiKey ) Begin { # By default PowerShell will not accept TLS 1.2 connections. # This can be fixed by running the code below. try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch { throw 'Unable to set PowerShell to accept TLS 1.2 connections, unable to continue.' } [Hashtable]$sessionHeaders = @{'X-Api-Key'=$ApiKey} [Uri]$hchkApiUri = 'https://healthchecks.io/api/v1/checks/' } Process { try { Invoke-RestMethod -Method Get -Uri $hchkApiUri -Headers $sessionHeaders | Out-Null [String]$script:SavedHealthCheckApi = $ApiKey } catch { $errorDetail = $_.Exception.Message Write-Error -Exception "Unable to authenticate with given APIKey.`n`r$errorDetail" ` -Message "Unable to authenticate with given APIKey.`n`r$errorDetail" -Category AuthenticationError } } }
PowerShellCorpus/PowerShellGallery/PS.HealthChecks/1.0.19/Public/Get-HealthCheck.ps1
Get-HealthCheck.ps1
using module ..\Class\Check.Class.psm1 function Get-HealthCheck { <# .SYNOPSIS The Get-HealthCheck cmdlet will list all checks associated with the account. .DESCRIPTION The Get-HealthCheck cmdlet will list all checks associated with the account. An API key is required to use this cmdlet. .EXAMPLE Get-HealthCheck Grace : 900 LastPing : Saturday, July 9, 2016 6:58:43 AM PingCount : 1 Name : Api test 1 NextPing : Saturday, July 9, 2016 7:58:43 AM PingURL : https://hchk.io/25c55e7c-8092-4d21-ad06-7dacfbb6fc10 Tags : foo Timeout : 3600 Grace : 60 LastPing : PingCount : 0 Name : Api test 2 NextPing : PingURL : https://hchk.io/7e1b6e61-b16f-4671-bae3-e3233edd1b5e Tags : bar baz Timeout : 60 The cmdlet above will return all checks for the account. .EXAMPLE PS C:\>Get-B2Bucket | Where-Object {$_.Name -eq 'Api test 2'} Grace : 60 LastPing : PingCount : 0 Name : Api test 2 NextPing : PingURL : https://hchk.io/7e1b6e61-b16f-4671-bae3-e3233edd1b5e Tags : bar baz Timeout : 60 The cmdlet above will return all buckets and search for the one with a name of "Api test 2". .INPUTS System.String This cmdlet takes the AccountID and ApplicationKey as strings. .OUTPUTS Check This cmdlet returns a check object for each check found. .LINK https://healthchecks.io/docs/ .ROLE PS.HealthChecks .FUNCTIONALITY PS.HealthChecks #> [CmdletBinding(SupportsShouldProcess=$false, PositionalBinding)] [Alias()] [OutputType([Check])] Param ( # The Api key for your account. [Parameter(Mandatory=$false)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [Uri]$ApiKey = $script:SavedHealthCheckApi ) Begin { if($ApiKey -eq $null){ throw 'The API key needs to be specified.' } # By default PowerShell will not accept TLS 1.2 connections. # This can be fixed by running the code below. try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch { throw 'Unable to set PowerShell to accept TLS 1.2 connections, unable to continue.' } [Hashtable]$sessionHeaders = @{'X-Api-Key'=$ApiKey} [Uri]$hchkApiUri = 'https://healthchecks.io/api/v1/checks/' } Process { $hchkInfo = Invoke-RestMethod -Method Get -Uri $hchkApiUri -Headers $sessionHeaders foreach($info in $hchkInfo.checks) { $hchkReturnInfo = [Check]::New($info.name, $info.tags, $info.timeout, $info.grace, $info.ping_url, $info.n_pings, $info.last_ping, $info.next_ping) Write-Output $hchkReturnInfo } } }
PowerShellCorpus/PowerShellGallery/PS.HealthChecks/1.0.19/Public/New-HealthCheck.ps1
New-HealthCheck.ps1
using module ..\Class\Check.Class.psm1 function New-HealthCheck { <# .SYNOPSIS New-HealthCheck will create a new health check. .DESCRIPTION New-HealthCheck will create a new health check. An API key is required to use this cmdlet. .EXAMPLE New-HealthCheck -Name stoic-barbarian-lemur -Tag "prod db-dump" Grace : 3600 LastPing : PingCount : 0 Name : stoic-barbarian-lemur NextPing : PingURL : https://hchk.io/25c55e7c-8092-4d21-ad06-7dacfbb6fc10 Tags : prod db-dump Timeout : 86400 The cmdlet above will create a new check with the name of stoic-barbarian-lemur and tags of "prod db-dump". All other options are set to default and are not required to be specified. .EXAMPLE PS C:\>New-HealthCheck Grace : 3600 LastPing : PingCount : 0 Name : NextPing : PingURL : https://hchk.io/25c55e7c-8092-4d21-ad06-7dacfbb6fc10 Tags : Timeout : 86400 The cmdlet above will create a new check with all default properties. .EXAMPLE PS C:\>New-HealthCheck -Grace 60 -Timeout 60 Grace : 60 LastPing : PingCount : 0 Name : NextPing : PingURL : https://hchk.io/25c55e7c-8092-4d21-ad06-7dacfbb6fc10 Tags : Timeout : 60 The cmdlet above will create a new check with grace and timeout set to the smallest value of 60 seconds. .EXAMPLE PS C:\>New-HealthCheck -Grace 604800 -Timeout 604800 Grace : 604800 LastPing : PingCount : 0 Name : NextPing : PingURL : https://hchk.io/25c55e7c-8092-4d21-ad06-7dacfbb6fc10 Tags : Timeout : 604800 The cmdlet above will create a new check with grace and timeout set to the largest value of 604800 seconds (1 week). .EXAMPLE PS C:\>New-HealthCheck -Channel "*" Grace : 3600 LastPing : PingCount : 0 Name : NextPing : PingURL : https://hchk.io/25c55e7c-8092-4d21-ad06-7dacfbb6fc10 Tags : Timeout : 86400 The cmdlet above will create a new check set to alarm on all integration channels. See more https://healthchecks.io/integrations/ .INPUTS System.String This cmdlet takes the check name, tags, channel, and API key as strings. System.UInt32 This cmdlets takes the grace and timout periods as unsigned, 32 bit integers. .OUTPUTS Check This cmdlet returns a check object for new check created. .LINK https://healthchecks.io/docs/ .ROLE PS.HealthChecks .FUNCTIONALITY PS.HealthChecks #> [CmdletBinding(SupportsShouldProcess, PositionalBinding, ConfirmImpact='Low')] [Alias()] [OutputType([Check])] Param ( # The name of the new check, maximum of 99 characters. [Parameter(Mandatory=$false)] [ValidateNotNull()] [ValidateLength(0,99)] [String[]]$Name = '', # Tag(s) for the check, maximum of 499 characters. [Parameter(Mandatory=$false)] [ValidateNotNull()] [ValidateLength(0,499)] [String]$Tag = '', # Timeout period for the check, maximum 604800 seconds (1 week). [Parameter(Mandatory=$false)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [ValidateRange(60,604800)] [UInt32]$Timeout = 86400, # Grace period for the check, maximum 604800 seconds (1 week). [Parameter(Mandatory=$false)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [ValidateRange(60,604800)] [UInt32]$Grace = 3600, # Alert channel to send notifications on, maximum of 49 characters. [Parameter(Mandatory=$false)] [ValidateNotNull()] [ValidateLength(0,49)] [String]$Channel = '', # Used to bypass confirmation prompts. [Parameter(Mandatory=$false)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [Switch]$Force, # The Api key for your account. [Parameter(Mandatory=$false)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [String]$ApiKey = $script:SavedHealthCheckApi ) Begin { if($ApiKey -eq $null){ throw 'The API key needs to be specified.' } # By default PowerShell will not accept TLS 1.2 connections. # This can be fixed by running the code below. try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch { throw 'Unable to set PowerShell to accept TLS 1.2 connections, unable to continue.' } [Hashtable]$sessionHeaders = @{'X-Api-Key'=$ApiKey} [Uri]$hchkApiUri = 'https://healthchecks.io/api/v1/checks/' } Process { foreach($check in $Name) { if($Force -or $PSCmdlet.ShouldProcess($check, "Create new check.")) { try { [String]$sessionBody = @{'name'=$check;'tags'=$Tag;'timeout'=$Timeout;'grace'=$Grace;'channels'=$Channel} | ConvertTo-Json $hchkInfo = Invoke-RestMethod -Method Post -Uri $hchkApiUri -Headers $sessionHeaders -Body $sessionBody $hchkReturnInfo = [Check]::New($hchkInfo.name, $hchkInfo.tags, $hchkInfo.timeout, $hchkInfo.grace, $hchkInfo.ping_url, $hchkInfo.n_pings, $hchkInfo.last_ping, $hchkInfo.next_ping) Write-Output $hchkReturnInfo } catch { $errorDetail = $_.Exception.Message Write-Error $errorDetail } } } } }
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMSCCMTask.Helper.ps1
Matrix42.EMPSSDK.EMSCCMTask.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM SCCM Tasks # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- #EMFolder (PSObject) function New-EMSCCMTaskObject { Param ( [int]$Id, [string]$Taskname, [string]$SCCMId, [ValidateSet('Application','Package')] [string]$PackageType, [ValidateSet('PushRollout','MassRollout')] [string]$RolloutType, [bool]$Archived = $false, [ValidateSet('Device','User')] [string]$TargetMode, [string]$CreatedBy, [string]$Owner, [int]$Threshold, [ValidateSet('Available','Required')] [string]$Purpose, [bool]$Predeploy, [bool]$WakeOnLan, [bool]$MeteredInternet, [ValidateSet('ShowTaskAndAllInfos','ShowTaskAndOnlyReboot','Hide')] [string]$UserExperiences, [bool]$Enabled = $true, [ValidateSet('None', 'Create', 'Active', 'Running', 'Finished', 'Error', 'Update', 'UpdateError', 'Delete' , 'Wait', 'Disabled', 'RequirementsNotMet')] [string]$Status = 'Active', [bool]$IsSuccessful = $false, [bool]$IsFailed = $false, $EMApiSCCMTask ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Create the object $o = New-Object -TypeName PSCustomObject # Write computer information to local logfile Add-KabompoLogLine -Message "Start creating a local EMSCCMTask-Object" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Id: $Id" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Taskname: $Taskname" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SCCMId: $SCCMId" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...PackageType: $PackageType" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...RolloutType: $RolloutType" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Archived: $Archived" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...TargetMode: $TargetMode" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Created By: $CreatedBy" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Owner: $Owner" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Threshold: $Threshold" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Purpose: $Purpose" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Predeploy: $Predeploy" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...WakeOnLan: $WakeOnLan" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...MeteredInternet: $MeteredInternet" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...UserExperience: $UserExperience" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Enabled: $Enabled" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Status: $Status" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...IsSuccessful: $IsSuccessful" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...IsFailed: $IsFailed" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Id" -Value $Id Add-Member -InputObject $o -MemberType NoteProperty -Name "Taskname" -Value $Taskname Add-Member -InputObject $o -MemberType NoteProperty -Name "SCCMId" -Value $SCCMId Add-Member -InputObject $o -MemberType NoteProperty -Name "PackageType" -Value $PackageType Add-Member -InputObject $o -MemberType NoteProperty -Name "RolloutType" -Value $RolloutType Add-Member -InputObject $o -MemberType NoteProperty -Name "Archived" -Value $Archived Add-Member -InputObject $o -MemberType NoteProperty -Name "TargetMode" -Value $TargetMode Add-Member -InputObject $o -MemberType NoteProperty -Name "CreatedBy" -Value $CreatedBy Add-Member -InputObject $o -MemberType NoteProperty -Name "Owner" -Value $Owner Add-Member -InputObject $o -MemberType NoteProperty -Name "Threshold" -Value $Threshold Add-Member -InputObject $o -MemberType NoteProperty -Name "Purpose" -Value $Purpose Add-Member -InputObject $o -MemberType NoteProperty -Name "Predeploy" -Value $Predeploy Add-Member -InputObject $o -MemberType NoteProperty -Name "WakeOnLan" -Value $WakeOnLan Add-Member -InputObject $o -MemberType NoteProperty -Name "MeteredInternet" -Value $MeteredInternet Add-Member -InputObject $o -MemberType NoteProperty -Name "UserExperience" -Value $UserExperience Add-Member -InputObject $o -MemberType NoteProperty -Name "Enabled" -Value $Enabled Add-Member -InputObject $o -MemberType NoteProperty -Name "Status" -Value $Status Add-Member -InputObject $o -MemberType NoteProperty -Name "IsSuccessful" -Value $IsSuccessful Add-Member -InputObject $o -MemberType NoteProperty -Name "IsFailed" -Value $IsFailed Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiSCCMTask" -Value $EMApiSCCMTask # Format the object Add-KabompoLogLine -Message "Add properties ""Taskname"", ""PackageType"", ""RolloutType"", ""Owner"", ""Status""" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $VisibleProperties = @("Taskname", "PackageType", "RolloutType", "Owner", "Status") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o -Verbose:$DoVerbose # Specify the type name $o.PSObject.TypeNames.Clear() Add-KabompoLogLine -Message "Add type name ""EMSCCMTask""" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $o.PSObject.TypeNames.Add("EMSCCMTask") Add-KabompoLogLine -Message "Finished creating a local EMSCCMTask-Object" -Component New-EMSCCMTaskObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMSCCMTaskObject -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMFolder=$null throw $_.Exception } } function Get-EMApiSCCMTaskLoad { Param ( [Parameter(Mandatory=$true,Position=0)] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [int]$SCCMTaskId ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMApiSCCMTask = $EMConnection.EMApiConnection.Sccm_Load($SCCMTaskId, $true) return $EMApiSCCMTask } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCis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/ # +ie7joU/pp2Q0ufWH5yIe2wEziIQIwq3+yG/6WmnPLUiaEFtSSv1yCeH7cfBhBw7 # f3m99L10DqihWRc5nfFIEee9jR5qJa0EGT8ImmKdv5kVffZLCuebCtkCVXxUTTgx # MMI6qx+kgjwgZtq0Tsr/wd8yHoY93IxvmZ2A/CswUaGaJh8kYRLZ9MTI0b22RzHx # YCfifiq17KFyJ7w8xhMe+zG3s1uJVuDcEitGG/DRHbJNniDtX7613dpQOWwL32dp # paV+1QKRHkc= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMSequences.ps1
Matrix42.EMPSSDK.EMSequences.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Sequences # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMSequences.Helper.ps1" # Create a new Sequence Object (will mainly use "New-EMSequenceObject") function New-EMSequence { Param ( [Parameter(Mandatory=$true, Position=1)] [ValidateNotNullorEmpty()] [string]$SequenceName, [Parameter(Mandatory=$false, Position=2)] $UserAccount=$null, [Parameter(Mandatory=$false, Position=3)] [int]$Version=1, [Parameter(Mandatory=$false, Position=4)] [int]$ParentFolderId=0 ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) if($Version -lt 1) { $Version = 1 } # Add inital line to logfile Add-KabompoLogLine -Message "Start creating a local sequence object" -Component New-EMSequence -Type 1 -Verbose:$DoVerbose # Create sequence object $EMApiSequence = New-Object Matrix42.EM.Contract.Container.v2.Sequence $EMApiSequence.Name=$SequenceName $EMApiSequence.Account=$UserAccount $EMApiSequence.Version=$Version $EMApiSequence.ID_Folder=$ParentFolderId # Create EM-PS Object $global:logIndention++ $EMSequence = New-EMSequenceObject -SequenceName $SequenceName -Version $Version -UserAccount $UserAccount -EMApiSequence $EMApiSequence -ParentFolderId $ParentFolderId $global:logIndention-- Add-KabompoLogLine -Message "Finished creating a local sequence object" -Component New-EMSequence -Type 1 -Verbose:$DoVerbose return $EMSequence } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMSequence -Type 3 -Verbose:$DoVerbose $EMApiSequence=$null throw $_.Exception } return $WcfResult } # Load sequences from EM Database function Get-EMSequence { <# .SYNOPSIS Get a sequence from the EM Server. .DESCRIPTION Get a sequence from the EM Server. You can search by it's ID or name and define if actions and conditions can be loaded or not. .EXAMPLE Get-EMSequence -SequenceId 28 .EXAMPLE Get-EMSequence -SequenceName "EMPSSDKTest" .EXAMPLE Get-EMSequence -SequenceName "EMPSSDKTest" -Actions -Conditions .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true, Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$false, Position=1)] [ValidateNotNullorEmpty()] [int]$SequenceId=0, [Parameter(Mandatory=$false, Position=2)] [string]$SequenceName, [Parameter(Mandatory=$false, Position=3)] [switch]$Actions = $false, [Parameter(Mandatory=$false, Position=4)] [switch]$Conditions = $false ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start loading a sequence" -Component Get-EMSequence -Type 1 -LogLevel 2 -Verbose:$DoVerbose if($Actions -eq $true) { Add-KabompoLogLine -Message "Load actions for sequence" -Component Get-EMSequence -Type 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "Load no actions for sequence" -Component Get-EMSequence -Type 1 -Verbose:$DoVerbose } if($Conditions -eq $true) { Add-KabompoLogLine -Message "Load conditions for sequence" -Component Get-EMSequence -Type 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "Load no conditions for sequence" -Component Get-EMSequence -Type 1 -Verbose:$DoVerbose } $EMApiSequenceList = @() if($SequenceId -ne 0) { Add-KabompoLogLine -Message "The sequence ID ""$SequenceId"" is given. Try to find the sequence by their ID and ignore name parameters." -Component Get-EMSequence -Type 1 -Verbose:$DoVerbose $EMApiSequence = $EMConnection.EMApiConnection.Sequences_Load($Actions, $Conditions, $SequenceId) if($EMApiSequence.Status.Type -ne "Failed") { $EMApiSequenceList += ,$EMApiSequence } } elseif(![String]::IsNullOrEmpty($SequenceName)) { Add-KabompoLogLine -Message "A sequence name ""$SequenceName"" is given. Try to find the sequence by its name." -Component Get-EMSequence -Type 1 -Verbose:$DoVerbose $result = $EMConnection.EMApiConnection.Sequences_Search($Actions, $Conditions, $SequenceName) if($result.Sequences.Count -eq 0) { Add-KabompoLogLine -Message "Finished loading a sequence. No result." -Component Get-EMSequence -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $null } elseif($result.Sequences.Count -ge 1) { foreach($r in $result.Sequences.Values) { $EMApiSequenceList += ,$r } } } else { throw "You have to declare an ID or the name of the sequence you want to search for." } Add-KabompoLogLine -Message "Successful read out one or more sequences with following ID(s): ""$($EMApiSequenceList.ID)""" -Component Get-EMSequence -Type 1 -Verbose:$DoVerbose foreach($i in $EMApiSequenceList) { $global:logIndention++ $EMSequence = New-EMSequenceObject -Id $i.ID -ParentFolderId $i.ID_Folder -Version $i.Version -UserAccount $i.Account -SequenceName $i.Name -EMApiSequence $i -EMConnection $EMConnection -Verbose:$DoVerbose $EMsequenceList += ,$EMSequence $global:logIndention-- } Add-KabompoLogLine -Message "Finished loading a sequence" -Component Get-EMSequence -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMSequenceList } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Get-EMSequence -Type 3 -Verbose:$DoVerbose $EMSequence=$null throw $_.Exception } } # Save a given sequence to the EM database function Save-EMSequence { <# .SYNOPSIS Saves the current sequence to EM. .DESCRIPTION Saves the current sequence to EM. An action is needed to save the sequence, use the sequence function "AddAction()" to add an action to the sequence .EXAMPLE Save-EMSequence -EMConnection $conn -EMSequence $s Will create a sequence when no other sequence is saved with same name in the same folder .EXAMPLE Save-EMSequence -EMConnection $conn -EMSequence $s -Force Will create a sequence, also when another sequence already exist with same name in the same folder .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] $EMSequence=$null, [Parameter(Mandatory=$false,Position=2)] [switch]$Force=$false ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start saving sequence to EM" -Component Save-EMSequence -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Just do something, when at minimum one action is given if($EMSequence.EMActionList.Count -le 0) { throw "You must provide at minimum one action to save the sequence to the EM-Server" } # Should an EM-Sequence be created, also when an sequence with same name already exist in given folder if(!$Force) { Add-KabompoLogLine -Message "It should not be possible to create a sequence if it's exist with same name. Search for existing sequence with name ""$($EMSequence.SequenceName)""." -Component Save-EMSequence -Type 1 -Verbose:$DoVerbose # Load sequences with same name $global:logIndention++ $EMExistingSequences = Get-EMSequence -EMConnection $EMConnection -SequenceName $EMSequence.SequenceName -Verbose:$DoVerbose $global:logIndention-- # Search for sequences with same name and parent id $test = $EMExistingSequences | Where-Object { $_.SequenceName -ieq $EMSequence.SequenceName -and $_.ParentFolderId -eq $EMSequence.ParentFolderId } # throw exception when sequence already exist if($test -ne $null) { throw "Failed to create sequence. Sequence with same name exist in the same folder" } Add-KabompoLogLine -Message "No sequence found." -Component Save-EMSequence -Type 1 -Verbose:$DoVerbose } # Check for parent folder. Add-KabompoLogLine -Message "Check if given parent folder exist." -Component Save-EMSequence -Type 1 -Verbose:$DoVerbose $global:logIndention++ if(!(Test-EMFolder -EMConnection $EMConnection -FolderId $EMSequence.ParentFolderId -FolderType Sequences -Verbose:$DoVerbose)) { $global:logIndention-- Add-KabompoLogLine -Message "Failed to get parent folder. Using root folder as alternative" -Component Save-EMSequence -Type 2 -Verbose:$DoVerbose $EMSequence.ParentFolderId = 0 } else { $global:logIndention-- } # If no user is given, try to load the user of the connection and add this user to the sequence $SequenceUserAccount = $EMSequence.UserAccount if([string]::IsNullOrEmpty($SequenceUserAccount)) { Add-KabompoLogLine -Message "No user given. Using user ""$($EMConnection.Account)"" from EMConnection as registered user for sequence." -Component Save-EMSequence -Type 2 -Verbose:$DoVerbose $SequenceUserAccount = $EMConnection.Account } # Check if given user is available in EM Database Add-KabompoLogLine -Message "Check if given user exist." -Component Save-EMSequence -Type 1 -Verbose:$DoVerbose $global:logIndention++ if(!(Test-EMUser -EMConnection $EMConnection -UserName $SequenceUserAccount -Verbose:$DoVerbose)) { throw "Unable to load user ""$SequenceUserAccount"" from EM Database." } $global:logIndention-- # Writer user information to EMSequence Object $EMSequence.EMApiSequence.Account = $SequenceUserAccount $EMSequence.UserAccount = $SequenceUserAccount # Save sequence to EM Database and get retrieved ID $objId = Save-EMApiSequence -EMConnection $EMConnection -EMSequence $EMSequence -Verbose:$DoVerbose # Update IDs on local object if($objId -ne $null) { $EMSequence.EMApiSequence.ID = $objId $EMSequence.Id=$objId foreach($action in $EMSequence.EMActionList) { $action.EMApiAction.ID_Sequence = $objId } } else { throw "Failed to retrieve ID from newly created object" } Add-KabompoLogLine -Message "Finished saving sequence to EM" -Component Save-EMSequence -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMSequence } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Save-EMSequence -Type 3 -Verbose:$DoVerbose throw $_.Exception } } function Test-EMSequence { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] [int]$SequenceId=$null ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start testing sequence." -Component Test-EMSequence -Type 1 -LogLevel 2 -Verbose:$DoVerbose $ret = $false Add-KabompoLogLine -Message "Get sequence by its ID." -Component Test-EMSequence -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMSequenceToTest = Get-EMSequence -EMConnection $EMConnection -SequenceId $SequenceId -Verbose:$DoVerbose $global:logIndention-- if($EMSequenceToTest -eq $null) { Add-KabompoLogLine -Message "No sequence with given ID found. Returning false." -Component Test-EMSequence -Type 1 -LogLevel 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "The given SequenceId ""$SequenceId"" was found." -Component Test-EMSequence -Type 1 -LogLevel 1 -Verbose:$DoVerbose $ret = $true } Add-KabompoLogLine -Message "Finished testing sequence. Result = $ret." -Component Test-EMSequence -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $ret } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Test-EMSequence -Type 3 -Verbose:$DoVerbose $global:logIndention = $localIndent throw $_.Exception } } function Remove-EMSequence { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] $EMSequence=$null, [Parameter(Mandatory=$true,Position=2)] [ValidateSet('AllReferences', 'OnlySequence', 'EmptyPlans')] $DeleteMode = "OnlySequence" ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start removing sequence from EM." -Component Remove-EMSequence -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Check if sequence exist in EM. $global:logIndention++ $checkSequence = Test-EMSequence -EMConnection $EMConnection -SequenceId $EMSequence.Id -Verbose:$DoVerbose $global:logIndention-- if(!($checkSequence)) { Add-KabompoLogLine -Message "Given sequence does not exist in EM Database." -Component Remove-EMSequence -Type 2 -LogLevel 1 -Verbose:$DoVerbose } else { $global:logIndention++ Remove-EMApiSequence -EMConnection $EMConnection -EMSequence $EMSequence -DeleteMode $DeleteMode -Verbose:$DoVerbose $global:logIndention-- } Add-KabompoLogLine -Message "Finished removing sequence from EM." -Component Remove-EMSequence -Type 1 -LogLevel 2 -Verbose:$DoVerbose } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Remove-EMSequence -Type 3 -Verbose:$DoVerbose $global:logIndention = $localIndent throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUhnQgdmJmgBDSuN3lwdrbueQS # eBSgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw # ggEKAoIBAQDHZNuFnBatHdyRnMUJ2Y1P6k49MjD04t9S7ukWj8upP/B6wPRYzzQf # 6QVMPKzMhNTPfIXaIEzi/jhT0jjwnXC0O9hF2rwTpDRnVOnVJemaqd2XsSDVEBUY # yhH7QZ82Zwi1nnSgo69WL694L3f74ge6bRiRIJ/IoZawj+74NL/9B93kGKH89sew # VtqPoDwSklJmzc86Qlgw6X/WXenHw8n6k/htEIjkHpiE6iG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oAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FF4fWrhLXxNW8hNSYmksH5+GAa0SMA0GCSqGSIb3DQEBAQUABIIBAMDcPJv3scbn # 1uiWmpka2vAdGV//mzCoSO6l8UvYV5nAjTqFP8U4FHC/FaMQY2B+NSVlDFE23N6R # IBb7mvDSUBlPG2yZQBXS/b2fg5KOM//riVm3K0dIfrC8fPIPwhT962R1FnY+1oGA # eA5tw4K9KfCxMsQMjG3DAojx7aouOqHS9F8/cwbnWSBrlV5tcmnC2hzxbWJRlbON # 6caE5GlDBqMpcDYpoXYopZsaHHt7tOKi6ke6ACDh3n8d0xo01nGWH/OzCxUMt/XB # eXeK3sjZk/x27UO/WLs52CrwrtfOLBxZIFv/o72eGnvwCEPj6+qkfMfsL4gdbPhU # w3Aj/qFW0C8= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMBase.ps1
Matrix42.EMPSSDK.EMBase.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: General functions # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMBase.Helper.ps1" function Open-EMConnection { <# .SYNOPSIS Builds up a connection to the "Matrix42 Enterprise Manager for SCCM" Server. .DESCRIPTION Builds up a connection to the "Matrix42 Enterprise Manager for SCCM" (EM) via the WebService Interface. Store this connection into a Powershell variable to use it for interaction with the EM-Server. .EXAMPLE Open-EMConnection -ServerName sv01.imagoverum.com Will build up a connection to the EM-Server with the credentials you currently use to log into your local Windows System. .EXAMPLE Open-EMConnection -ServerName sv01.imagoverum.com -EMApiVersion 6.4.0.16312 Will build up a connection to the EM-Server with the credentials you currently use to log into your local Windows System. The Api Version 6.4.0.16312 is used. The version should match the version you currently use on your EM-Server system. .EXAMPLE Open-EMConnection -ServerName sv01.imagoverum.com -SdkPort 8099 Will build up a connection to the EM-Server with the credentials you currently use to log into your local Windows System. With the SdkPort parameter you can choose the port which is beeing used to connect to the EM-Server. .EXAMPLE Open-EMConnection -ServerName sv01.imagoverum.com -Account mmiller -Password Coffee2Go Will build up a connection to the EM-Server with a dedicated account. .EXAMPLE Open-EMConnection -ServerName sv01.imagoverum.com -Language de -DiffToUtc 240 Will build up a connection to the EM-Server with the credentials you currently use to log into your local Windows System. With the "Language" parameter you choose, in which language the EM-Server will return error messages. With "DiffToUtc" you specify your timezone to let calculate the EM-Server the right time for objects you create. .NOTES If you want to work on several EM Server versions within the same Powershell instance you have to decide which version of the EMApi should be used for both, because of limitations in Powershell (You can just load one version of DLL in every PS-Host). .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] [string]$ServerName, [Parameter(Mandatory=$false,Position=1)] [int]$SdkPort=8099, [Parameter(Mandatory=$true,Position=2)] [string]$Account=$null, [Parameter(Mandatory=$true,Position=3)] [string]$Password=$null, [Parameter(Mandatory=$false,Position=4)] [ValidateSet("de","en")] [string]$Language="en", [Parameter(Mandatory=$false,Position=5)] [int]$DiffToUtc=120, [Parameter(Mandatory=$false,Position=6)] [ValidateSet("6.4.0.16312","6.5.0.17117","7.0.0.16340","7.0.0.16353","7.0.1.17044","7.0.1.17065","7.0.3.17103")] [string]$EMApiVersion="7.0.3.17103" ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMConnection = $null Add-KabompoLogLine -Message "Start connecting to the EM-Server" -Component Open-EMConnection -Type 1 -LogLevel 1 -Verbose:$DoVerbose Add-KabompoLogLine -Message "Create a connection object with following parameters:" -Component Open-EMConnection -Type 1 -LogLevel 2 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Servername: $ServerName" -Component Open-EMConnection -Type 1 -LogLevel 2 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SdkPort: $SdkPort" -Component Open-EMConnection -Type 1 -LogLevel 2 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Account: $Account" -Component Open-EMConnection -Type 1 -LogLevel 2 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Password: ********" -Component Open-EMConnection -Type 1 -LogLevel 2 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Language: $Language" -Component Open-EMConnection -Type 1 -LogLevel 2 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...DiffToUtc: $DiffToUtc" -Component Open-EMConnection -Type 1 -LogLevel 2 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...EMApiVersion: $EMApiVersion" -Component Open-EMConnection -Type 1 -LogLevel 2 -Verbose:$DoVerbose $global:logIndention++ Register-EMSdk -EMApiVersion $EMApiVersion -Verbose:$DoVerbose $global:logIndention-- $EMApiConnection = New-Object Matrix42.EM.Sdk.API.ApiConnect $ServerName, $SdkPort, $Account, $Password, $Language, $DiffToUtc $global:logIndention++ $EMConnection = New-EMConnectionObject -ServerName $ServerName -SdkPort $SdkPort -Account $Account -Language $Language -DiffToUtc $DiffToUtc -EMApiConnection $EMApiConnection -EMApiVersion $EMApiVersion -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Finished connecting to the EM-Server ""$ServerName""." -Component Open-EMConnection -Type 1 -LogLevel 1 -Verbose:$DoVerbose return $EMConnection } catch { Add-KabompoLogLine "Something went wrong" -ErrorMessage $_.Exception.Message -Component Open-EMConnection -Type 3 -Verbose:$DoVerbose $ApiConnect=$null $EMConnection=$null $global:logIndention = $localIndent throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEA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DqII34jSuTQgEd+0aGarkqgiDWKqevW6VCyUES0+nG4fZw # j6xYOlAkl1+M3QhSVAVnWr4z5RjMhXYteU07PQkXi3org2mV06LEtyM0FEfg5hkr # GY0w3voQxesF96yyG0C092r1qMMfKlg5Huh6rMKM6B/ZQet1s9H0Mnyb+RI6kN01 # vYUE40E9nWM= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMComputergroups.Helper.ps1
Matrix42.EMPSSDK.EMComputergroups.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Computergroups # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUp6JtsoGunujOy70y3rdzWzT8 # 0VugggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBA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jECAQEwgZMwfzELMAkGA1UEBhMCVVMxHTAb # BgNVBAoTFFN5bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FOs4x72fp81Mr1aMmDz3352i7WoYMA0GCSqGSIb3DQEBAQUABIIBAJPYRnfsq58g # LR6piORA2qI3jX7PCpo+/rDs58amiDOneMeZwnHBvbsG5qDdgRCN0dMc0KL0nV8n # 8OeE+xj0Y+HADvfyJiYLgYbt2709TY9OEccsGNYtZOQItDyFbU1D1vIEVscETjpz # FCEMOCTpnn9jHbRQgrjMNANgCNG3B01kVhU8cxTkXhcI45Wh72olRlter0PjSayk # qISu5aljPvHdcsr8K2zJz8AagR8rA8eAT3EF422TJJkWLzSdRDFzx8kIS1vGn7+M # 9EDZoef6GFYfuq4RYN8wbC1oqalNPNqNVXWLJCL+MuFg7m9hNrDSghwYodJ7NuWk # wRK2sbKNhXQ= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMComputergroups.ps1
Matrix42.EMPSSDK.EMComputergroups.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Computergroups # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMComputergroups.Helper.ps1" # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCD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FrtO7YBGX+aybR265z/6tIS8tN5m45I # F/WljR6BO7gEzChSJbadwtoKXulr0++QO+oRhNWs+FbqjkQ5bgC7y5sf0MwyQDdI # tMbGUXpMF2D4y4bk3QtfxPN3G9BLJ9FvQv+O9B3gr0sMUpVWoimLWwk9Mlj9UIlL # CXlsQ1ViYbSKHEz22IdIqlvdOaeu7mJirNjr9kP45pGyNFpL6Uf612SDfp6gS9rr # bQrRiSf5K/voEUUTBat4DYf78kysdY4tOZacVELft7uz7vk77AljDD0NmHl5MgFt # Iu/P5+K0NIc= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMComputer.Helper.ps1
Matrix42.EMPSSDK.EMComputer.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Computer # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- function New-EMComputerObject { Param ( [string]$Hostname, [bool]$Archived, [string]$Domain, [string]$LDAPPath, [string[]]$MACAddresses, [string]$MainUser, [string]$SccmGuid, [DateTime]$LastSccmHWScan, [string]$SccmSiteCode, [string]$SccmVersion, [string]$EMVersion, [string]$SerialNumber, [string]$SpecialValue1, [string]$SpecialValue2, $EmApiComputer ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Create a new object $o = New-Object -TypeName PSCustomObject # Wirte computer information to local logfile Add-KabompoLogLine -Message "Start creating a local EMComputer-Object" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Hostname: $Hostname" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Archived: $Archived" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Domain: $Domain" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...LDAPPath: $LDAPPath" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...MACAddresses: $MACAddresses" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...MainUser: $MainUser" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SccmGuid: $SccmGuid" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...LastSccmHWScan: $LastSccmHWScan" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SccmSiteCode: $SccmSiteCode" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SccmVersion: $SccmVersion" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...EMVersion: $EMVersion" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...serialNumber: $serialNumber" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SpecialValue1: $SpecialValue1" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SpecialValue2: $SpecialValue2" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Hostname" -Value $Hostname Add-Member -InputObject $o -MemberType NoteProperty -Name "Archived" -Value $Archived Add-Member -InputObject $o -MemberType NoteProperty -Name "Domain" -Value $Domain Add-Member -InputObject $o -MemberType NoteProperty -Name "LDAPPath" -Value $LDAPPath Add-Member -InputObject $o -MemberType NoteProperty -Name "MACAddresses" -Value $MACAddresses Add-Member -InputObject $o -MemberType NoteProperty -Name "MainUser" -Value $MainUser Add-Member -InputObject $o -MemberType NoteProperty -Name "SccmGuid" -Value $SccmGuid Add-Member -InputObject $o -MemberType NoteProperty -Name "LastSccmHWScan" -Value $LastSccmHWScan Add-Member -InputObject $o -MemberType NoteProperty -Name "SccmSiteCode" -Value $SccmSiteCode Add-Member -InputObject $o -MemberType NoteProperty -Name "SccmVersion" -Value $SccmVersion Add-Member -InputObject $o -MemberType NoteProperty -Name "EMVersion" -Value $EMVersion Add-Member -InputObject $o -MemberType NoteProperty -Name "SerialNumber" -Value $serialNumber Add-Member -InputObject $o -MemberType NoteProperty -Name "SpecialValue1" -Value $SpecialValue1 Add-Member -InputObject $o -MemberType NoteProperty -Name "SpecialValue2" -Value $SpecialValue2 Add-Member -InputObject $o -MemberType NoteProperty -Name "EmApiComputer" -Value $EmApiComputer # Format the object Add-KabompoLogLine -Message "Add properties ""Hostname"", ""MainUser"", ""SccmGuid"", ""SerialNumber""" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $VisibleProperties = @("Hostname", "MainUser", "SccmGuid", "SerialNumber") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o -Verbose:$DoVerbose # Specify the type name $o.PSObject.TypeNames.Clear() Add-KabompoLogLine -Message "Add type name ""EMComputer""" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $o.PSObject.TypeNames.Add("EMComputer") Add-KabompoLogLine -Message "Finished creating a local EMComputer-Object" -Component New-EMComputerObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMComputerObject -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMComputer=$null throw $_.Exception } } function Get-EMApiComputerSearch { Param ( [Parameter(Mandatory=$true,Position=0)] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] $Hostname ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMApiComputer = $null $EMApiComputer = $EMConnection.EMApiConnection.Computer_Load($Hostname) } catch {} # Beispiel um Inventardaten zu laden #$colNames = @() #$colNames += "Biosname" #$colNames += "BiosVersion" #$ComputerInventoryData = $EMConnection.EMApiConnection.InventoryData_Load("MUC_Hardware_Bios", $colNames, $ComputerName) # Gibt ein Dictionary mit "<string>,<Table>" zur³ck #$ComputerInventoryData.Table.Values[0] # Greift auf die Tabelle "MUC_Hardware_Bios" zu #$ComputerInventoryData.Table.Values[0].Columns[0] # Liest den ersten Spaltenname aus (Hostname) #$ComputerInventoryData.Table.Values[0].Columns[1] # Liest den zweiten Spaltenname aus (Biosname) ... #$ComputerInventoryData.Table.Values[0].Rows[0] # Liest den ersten Wert aus (PC02) #$ComputerInventoryData.Table.Values[0].Rows[1] # Liest den zweiten Wert aus (Biosname) .... # EM does return a "computer" object with no hostname when you are searching for a computer that doesn't exist if($EMApiComputer.Hostname -eq $null) { $EMApiComputer = $null } return $EMApiComputer } function Save-EMApiComputer { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] $EMComputer ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Create the updateflag which is used to notify that the folder is newly created #$UpdateFlag = New-Object -TypeName Matrix42.EM.Contract.Container.v2.UpdateFlag "New" # Save the sequence to EM Add-KabompoLogLine -Message "Write EMComputer with status ""New"" to EM-Database." -Component Save-EMApiComputer -Type 1 -LogLevel 0 -Verbose:$DoVerbose $Status = $EMConnection.EMApiConnection.Computer_Save($EMComputer.EMApiComputer) # Give feedback about the result. If failed raise an exception if ($Status.Type -eq "Success") { Add-KabompoLogLine -Message "Successful written computer to EM-Database. ID is not shown because it doesn't exist for computer objects." -Component Save-EMApiComputer -Type 1 -LogLevel 0 -Verbose:$DoVerbose } else { $message = "{0} {1}" -f $this.EMApiComputer.Status.Message, $this.EMApiComputer.Status.SystemMessage throw $message } } function Remove-EMApiComputer { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] $EMComputer ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Save the sequence to EM Add-KabompoLogLine -Message "Remove EMComputer from EM-Database." -Component Remove-EMApiComputer -Type 1 -LogLevel 0 -Verbose:$DoVerbose $Status = $EMConnection.EMApiConnection.Computer_Delete($EMComputer.Hostname) # Give feedback about the result. If failed raise an exception if ($Status.Type -eq "Success") { Add-KabompoLogLine -Message "Successful removed computer from EM-Database." -Component Remove-EMApiComputer -Type 1 -LogLevel 0 -Verbose:$DoVerbose } else { $message = "{0} {1}" -f $this.EMApiComputer.Status.Message, $this.EMApiComputer.Status.SystemMessage throw $message } } function Add-EMComputerApiComputerToGroup { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] $EMComputer, [Parameter(Mandatory=$true,Position=2)] $EMGroupId ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Save the sequence to EM Add-KabompoLogLine -Message "Add EMComputer to computergroup with ID." -Component Add-EMComputerApiComputerToGroup -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Call EM API function to add the computer to the group $Status = $EMConnection.EMApiConnection.ComputerGroup_AddMember($EMGroupId, $EMComputer.Hostname) # Give feedback about the result. If failed raise an exception if ($Status.Type -eq "Success") { Add-KabompoLogLine -Message "Successful added EMComputer to computergroup with ID." -Component Add-EMComputerApiComputerToGroup -Type 1 -LogLevel 0 -Verbose:$DoVerbose } else { $message = "{0} {1}" -f $this.EMApiComputer.Status.Message, $this.EMApiComputer.Status.SystemMessage throw $message } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAM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ofHKZ9Gi/6lG8eL8lsPEVtdcnTo0M2im+7RFXjLcH++2QP # 4iNKVvs7wpi+Tm8RlzgEfuys0ppY6DCCwWu1YwoKmXhbl8Xg8pJhe+LdhM89sAm0 # huzidPqNu+z3cGk1UQMT3NkAkuC9wU9fvIKzP2X089x7ftYHiS8qZus5iJ1b/GcX # QA1uWNU9LJk= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMFolder.Helper.ps1
Matrix42.EMPSSDK.EMFolder.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Folder # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- #EMFolder (PSObject) function New-EMFolderObject { Param ( [int]$Id, [int]$ParentFolderId, [ValidateSet('Rolloutplans','Sequences','Variables','SccmPackages','Applications','Locations','Roles','Computergroups','UpdateList','OsdConfig','None')] [string]$FolderType, [string]$DeFolderName, [string]$EnFolderName, $EMApiFolder ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) if($FolderType -ieq "none") { throw "You have to provide a type for the new folder object" } # Create the object $o = New-Object -TypeName PSCustomObject # Add localized object for folder name $loName = New-EMLocalizationObject -deDE $DeFolderName -enUS $EnFolderName # Wirte computer information to local logfile Add-KabompoLogLine -Message "Start creating a local EMFolder-Object" -Component New-EMFolderObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Id: $Id" -Component New-EMFolderObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ParentFolderId: $ParentFolderId" -Component New-EMFolderObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...FolderType: $FolderType" -Component New-EMFolderObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Localized FolderName: $($loName.Value)" -Component New-EMFolderObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Id" -Value $Id Add-Member -InputObject $o -MemberType NoteProperty -Name "ParentFolderId" -Value $ParentFolderId Add-Member -InputObject $o -MemberType NoteProperty -Name "FolderType" -Value $FolderType Add-Member -InputObject $o -MemberType NoteProperty -Name "FolderName" -Value $($loName.Value) Add-Member -InputObject $o -MemberType NoteProperty -Name "FolderLocalizedNames" -Value $loName Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiFolder" -Value $EMApiFolder #region Function to modify the parent ID of the object $fChangeParentId = { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $ParentFolderId=$null ) try { Add-KabompoLogLine -Message "Start changing folder ID" -Component "EMFolder.ChangeParentId" -Type 1 -LogLevel 2 -Verbose:$DoVerbose $oldParentFolderId = $this.ParentFolderId $this.ParentFolderId = $ParentFolderId $this.EMApiFolder.ParentID = $ParentFolderId Add-KabompoLogLine -Message "Finished changing folder ID from ""$oldParentFolderId"" to ""$ParentFolderId""" -Component "EMFolder.ChangeParentId" -Type 1 -LogLevel 2 -Verbose:$DoVerbose } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component "EMFolder.ChangeParentId" -Type 3 -LogLevel 1 -Verbose:$DoVerbose throw $_.Exception } } Add-Member -InputObject $o -MemberType ScriptMethod -Name "ChangeParentId" -Value $fChangeParentId # Format the object Add-KabompoLogLine -Message "Add properties ""FolderName"", ""FolderType""" -Component New-EMFolderObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $VisibleProperties = @("FolderName", "FolderType") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o -Verbose:$DoVerbose # Specify the type name $o.PSObject.TypeNames.Clear() Add-KabompoLogLine -Message "Add type name ""EMFolder""" -Component New-EMFolderObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $o.PSObject.TypeNames.Add("EMFolder") Add-KabompoLogLine -Message "Finished creating a local EMFolder-Object" -Component New-EMFolderObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMFolderObject -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMFolder=$null throw $_.Exception } } function Get-EMApiFolderSearch { Param ( [Parameter(Mandatory=$true,Position=0)] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [string]$FolderType, [Parameter(Mandatory=$true,Position=2)] [string]$FolderName ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMApiFolder = @() try { $EMApiFolder = $EMConnection.EMApiConnection.Folder_Search($FolderType, $FolderName) } catch { } return $EMApiFolder } function Get-EMApiFolderLoad { Param ( [Parameter(Mandatory=$true,Position=0)] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [int]$FolderId ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMApiFolder = $EMConnection.EMApiConnection.Folder_Load($FolderId) return $EMApiFolder } function Save-EMApiFolder { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] $EMFolder ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Create the updateflag which is used to notify that the folder is newly created $UpdateFlag = New-Object -TypeName Matrix42.EM.Contract.Container.v2.UpdateFlag "New" # Save the folder to EM Add-KabompoLogLine -Message "Write folder with status ""New"" to EM-Database." -Component Save-EMApiFolder -Type 1 -LogLevel 0 -Verbose:$DoVerbose $EMFolder.EMApiFolder.Status = $EMConnection.EMApiConnection.Folder_Save($UpdateFlag, $EMFolder.EMApiFolder) # Give feedback about the result. If failed raise an exception if ($EMFolder.EMApiFolder.Status.Type -eq "Success") { Add-KabompoLogLine -Message "Successful written folder to EM-Database with ID ""$($EMSequence.Id)""" -Component Save-EMApiFolder -Type 1 -LogLevel 0 -Verbose:$DoVerbose return $EMFolder.EMApiFolder.Status.ID } else { $message = "{0} {1}" -f $this.EMApiFolder.Status.Message, $this.EMApiFolder.Status.SystemMessage throw $message } } function Remove-EMApiFolder { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] $EMFolder, [Parameter(Position=2)] [bool]$Recurse ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Using EM-Api to delete EMFolder from EM Database" -Component Remove-EMApiFolder -Type 1 -LogLevel 0 -Verbose:$DoVerbose $result = $EMConnection.EMApiConnection.Folder_Delete($EMFolder.Id, $Recurse) if($result.Type -eq "Failed") { throw "Failed to remove folder from database. Details: $($result.SystemMessage)" } Add-KabompoLogLine -Message "Successful remove folder with ID ""$folderId"" from EM-Database." -Component Remove-EMApiFolder -Type 1 -LogLevel 0 -Verbose:$DoVerbose } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU+zLTU2Y9bShDt/zWr/cwuMH0 # xgagggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQ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tUviuEXg+mw3QFCu+Xw4kisR93873N # Q9TxTKk/tYuEr2Ty0BQhMYICNTCCAjECAQEwgZMwfzELMAkGA1UEBhMCVVMxHTAb # BgNVBAoTFFN5bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FOg1BNjJVCN8JHv17P7lZT74djo6MA0GCSqGSIb3DQEBAQUABIIBAFihl6K+EEru # gbgN9xAoEWFFzukgoOo7j9cVGi0Ff5QkK441yHhhi5htJv1EEHmCfyqd0rPeg6zm # zSW/aD30/7KFuUJ1JvMKn55pnYBAEjH7l5ckyXi1e7/M0kS5LGw+rnapPXo3qU0M # aUQ1j7yxC3AYmIgi1aUw5Fq3mBkLfdYg3mIt1E9nqtI6Q8Xj+pnzQY2DY7kQFph2 # XxSU3refi+4JxOV/bUorkTWR4iA7AdkbGJ6sl9JyPI+Zgi7OR7CozNCJsSlXRPCS # 41V4EOHdfDLzEc5IiOndUR3vEbC9va2yBbJJfJ2uy6kKfr5qkKUiSttGIz9nAyTO # kKrSWjefhbA= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.Variables.ps1
Matrix42.EMPSSDK.Variables.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Variables that can be changed by customer # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- # Will be initialized by Matrix42.EMPSSDK.Logging.Init-Logging $global:EMPSSdkLog="$($PSScriptRoot)\log\empssdk.log" # Do you want to output all Log to the console (will only work, when console oder ise is attached to process) $global:LogToConsole=$true # Detail Level of Logfiles (0 = Debug, 1 = Normal, 2 = Minimalistic, 3 = Off) # 0 Should be used in all Helper files # 1 Should be used for normal information in methods the user can call # 2 Should be used for "start" and "end" lines of a method (for methods the user can call) $global:LogDetailLevel = 0 $global:LogMaxSize = 8192 $global:LogMaxAge = 10 # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUJ/+QVyF1AQ6XwXeEKGKnF+QX # VfigggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw # ggEKAoIBAQDHZNuFnBatHdyRnMUJ2Y1P6k49MjD04t9S7ukWj8upP/B6wPRYzzQf # 6QVMPKzMhNTPfIXaIEzi/jhT0jjwnXC0O9hF2rwTpDRnVOnVJemaqd2XsSDVEBUY # yhH7QZ82Zwi1nnSgo69W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b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FKAn/G7JJjtn2Mll0E6KTrUmLBaCMA0GCSqGSIb3DQEBAQUABIIBAHrvGrzEohSW # y9w64pm9nNI95cj7rQR48uQMAFBnS44s2rbLJuc6qk30nHT6cKwQunupZclb2a/b # fCAoq5eqZ6g8yIY/hvAu015F+f+wFPJMrO6mC6KMQSWk372G+l8qSyqYAiQASmfV # xKIf08q8A8bqOebjkI6ribMBhRMLi5jsqAY3oSMqQchuU9M7nH/goParJOEVx8DQ # DDG+vaHF5a20KV1E/lYF73FdElwFW3eXbCBhPm1hZa+aKGO93o2Fv8nryo9CZw/Q # 8xzCVSgHPAVz4cfZ5ITwFJ07ZgkZ8BcvMMUJafYfLmGK4wrQAynzqx4RanQXqHg8 # ycs92M84qTQ= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMUser.ps1
Matrix42.EMPSSDK.EMUser.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Users # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMUser.Helper.ps1" # Create a new User Object (will mainly use "New-EMUserObject") function New-EMUser { Param ( [Parameter(Mandatory=$true, Position=0)] [ValidateNotNullorEmpty()] [string]$Account, [Parameter(Mandatory=$true, Position=1)] [ValidateSet("AD","System")]#,"Team","None")] [string]$AccountType, [Parameter(Mandatory=$false, Position=2)] [ValidateSet("de","en")] [string]$Language, [Parameter(Mandatory=$false, Position=3)] [bool]$Animations ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Add inital line to logfile Add-KabompoLogLine -Message "Start creating a local user object" -Component New-EMUser -Type 1 -Verbose:$DoVerbose # Create sequence object $EMApiUser = New-Object Matrix42.EM.Contract.Container.v2.User $Account $EMApiUser.Animations = $Animations $EMApiUser.ID = 0 $EMApiUser.Language = $Language $EMApiUser.Type = $AccountType # Create EM-PS Object $global:logIndention++ #$EMUser = New-EMUserObject -Account $Account -AccountType $AccountType -FirstName $FirstName -LastName $LastName -Department $Department -DisplayName $DisplayName -EMail $EMail -Archived $Archived -Language $Language -Animations $Animations -EMApiUser $EMApiUser $EMUser= New-EMUserObject -Account $Account -AccountType $AccountType -Language $Language -Animations $Animations -EMApiUser $EMApiUser $global:logIndention-- Add-KabompoLogLine -Message "Finished creating a local sequence object" -Component New-EMUser -Type 1 -Verbose:$DoVerbose return $EMUser } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMUser -Type 3 -Verbose:$DoVerbose $EMApiUser=$null throw $_.Exception } return $WcfResult } function Get-EMUser { <# .SYNOPSIS Read out an account object from EM. .DESCRIPTION Read out an account object from EM. An account is used for authentication at EM and also being used to be associated with EM-Objects as owner. .EXAMPLE Get-EMUser -EMConnection $conn -UserName "ddelirium" .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection= $null, [Parameter(Mandatory=$true,Position=1)] [string]$UserName ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start loading an user object from EM." -Component Get-EMUser -Type 1 -LogLevel 2 -Verbose:$DoVerbose $EMApiUser = Get-EMApiUser $UserName Add-KabompoLogLine -Message "Received user ""$($EMApiUser.User.Account)"" with ID ""$($EMApiUser.User.Id)""" -Component Get-EMUser -Type 1 -LogLevel 1 -Verbose:$DoVerbose if($EMApiUser -ne $null -and $EMApiUser.User.ID -ne 0) { $global:logIndention++ $EMUser = New-EMUserObject -Id $EMApiUser.User.ID -Account $EMApiUser.User.Account -AccountType $EMApiUser.User.Type -FirstName $EMApiUser.Employee.Firstname -LastName $EMApiUser.Employee.Lastname -Department $EMApiUser.Employee.Department -DisplayName $EMApiUser.Employee.DisplayName -EMail $EMApiUser.Employee.Email -Archived $EMApiUser.Employee.Archived -Language $EMApiUser.User.Language -Animations $EMApiUser.User.Animations -EMApiUser $EMApiUser -EMConnection $EMConnection -Verbose:$DoVerbose $global:logIndention-- } else { $EMUser=$null } Add-KabompoLogLine -Message "Finished loading user object from EM. Returned ID = $($EMUser.Id)." -Component Get-EMUser -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMUser } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Get-EMUser -Type 3 -Verbose:$DoVerbose $EMUser=$null throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUvGzjYBrVn41/FlRBLqEOifNd # JgagggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # M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+mw3QFCu+Xw4kisR93873N # Q9TxTKk/tYuEr2Ty0BQhMYICNTCCAjECAQEwgZMwfzELMAkGA1UEBhMCVVMxHTAb # BgNVBAoTFFN5bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FDjyxtcAkAPQm162LPIxCi4d/NZKMA0GCSqGSIb3DQEBAQUABIIBAMNkAvKj0MVX # R+elSzre5Y2wF9hh2LQE8zu1/JoEYfU76ZhnxGhHn5PM4e5qm2T8Cxv4X95wTr5I # kICss4qkgX3bZWXgMFeMPhrR+aVtEqI43wq1p1PA7g+pHWdyIVgIb6Rvp1C05dx7 # ohZSbAIZ0IAPCdNfCPVuWIe5Zl7u9Nc4egfYmyoaJ7dxgzpKrHhqsHo7CWa6omHL # UaQvRlc9b+Pf7+oCSPg3JIrgJhjvm3MlDRcK02ItUWP6LGASGEmSwO36pRG9SCSu # Phw9r/onQaCJmhHFMLV9oQHxLcH5Jl9iiAA259jdrHeOlFHL4FrpcTklkma8xvjd # 2s19oeI72gk= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMRolloutplans.Helper.ps1
Matrix42.EMPSSDK.EMRolloutplans.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Rolloutplans # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- #EMRolloutplan (PSObject) function New-EMRolloutplanObject { Param ( [int]$Id=0, [string]$Caption, [string]$ReleasegroupId, [string]$ParentFolderId=0, [string]$DeDescription, [string]$EnDescription, [int]$Version=1, [string]$UserAccount=$null, [Matrix42.EM.Contract.Container.v2.RolloutPlan]$EMApiRolloutplan ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Create the object $o = New-Object -TypeName PSCustomObject # Add localized object for folder name $loDescription = New-EMLocalizationObject -deDE $DeDescription -enUS $EnDescription Add-KabompoLogLine -Message "Start creating a local EMRolloutplan Object" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Id: $Id" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Caption: $Caption" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ReleaseGroupId: $ReleasegroupId" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ParentFolderId: $ParentFolderId" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Localized Description: $($loDescription.Value)" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Version: $Version" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...UserAccount: $UserAccount" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Id" -Value $Id Add-Member -InputObject $o -MemberType NoteProperty -Name "Caption" -Value $Caption Add-Member -InputObject $o -MemberType NoteProperty -Name "ReleasegroupId" -Value $ReleasegroupId Add-Member -InputObject $o -MemberType NoteProperty -Name "ParentFolderId" -Value $ParentFolderId Add-Member -InputObject $o -MemberType NoteProperty -Name "Description" -Value $($loDescription.Value) Add-Member -InputObject $o -MemberType NoteProperty -Name "LocalizedDescription" -Value $loDescription Add-Member -InputObject $o -MemberType NoteProperty -Name "Version" -Value $Version Add-Member -InputObject $o -MemberType NoteProperty -Name "UserAccount" -Value $UserAccount Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiRolloutplan" -Value $EMApiRolloutplan Add-Member -InputObject $o -MemberType NoteProperty -Name "EMConnection" -Value $EMConnection Add-Member -InputObject $o -MemberType NoteProperty -Name "EMSequenceList" -Value $null # Initialize empty List for actions $o.EMSequenceList = @() #region Function to add one or more EMActions to the current sequence $fAddSequence = { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $Sequence=$null, [Parameter(Mandatory=$false,Position=1)] [switch]$Verbose=$false ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start adding a sequence to the EMRolloutplan" -Component "EMRolloutplan.AddSequence" -Type 1 -LogLevel 2 -Verbose:$DoVerbose # check if the right object is given if(!$Sequence.PSObject.TypeNames.Contains("EMSequence")) { throw "You must provide an object from type ""EMSequence""" } if($this.EMSequenceList.Contains($Sequence)) { Add-KabompoLogLine -Message "Selected sequence ""$($Sequence.SequenceName)"" is already in list." -Component "EMSequence.AddSequence" -Type 2 -LogLevel 1 -Verbose:$DoVerbose } else { $this.EMSequenceList += $Sequence Add-KabompoLogLine -Message "Added sequence to list. Currently there are ""$($this.EMSequenceList.Count)"" Sequences in list." -Component "EMSequence.AddSequence" -Type 1 -LogLevel 1 -Verbose:$DoVerbose } # Sync sequences to EMApiObject $this.EMApiRolloutplan.Sequences.Clear() foreach($s in $this.EMSequenceList) { $this.EMApiRolloutplan.Sequences.Add($s.Id) } Add-KabompoLogLine -Message "Finished adding a sequence ""$($Sequence.SequenceName)"" to EMRolloutplan ""$($this.Caption)""" -Component "EMRolloutplan.AddSequence" -Type 1 -LogLevel 2 -Verbose:$DoVerbose } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component "EMRolloutplan.AddSequence" -Type 3 -LogLevel 1 -Verbose:$DoVerbose throw $_.Exception } } Add-Member -InputObject $o -MemberType ScriptMethod -Name "AddSequence" -Value $fAddSequence #endregion # Format the object Add-KabompoLogLine -Message "Add properties ""Caption"", ""Description"", ""Version"", ""UserAccount""" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $VisibleProperties = @("Caption", "Description", "Version", "UserAccount") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o -Verbose:$DoVerbose # Specify the type name $o.PSObject.TypeNames.Clear() Add-KabompoLogLine -Message "Add type name ""EMRolloutplan""" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $o.PSObject.TypeNames.Add("EMRolloutplan") Add-KabompoLogLine -Message "Finished creating a local EMRolloutplan Object" -Component New-EMRolloutplanObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMRolloutplanObject -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMRolloutplan=$null throw $_.Exception } } function Save-EMApiRolloutplan { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] $EMRolloutplan ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Drop sequence IDs in API-Object-List (and refresh them after saving local objects to EM) $EMRolloutplan.EMApiRolloutplan.Sequences.Clear() # Save sequences that are just exist in local memory and snyc sequence IDs to sequencelist in API object foreach($s in $EMRolloutplan.EMSequenceList) { if($s.ID -eq 0) { try { # Overwrite object in sequence-list $s = Save-EMSequence -EMConnection $EMConnection -EMSequence $s } catch { throw "Cannot save rollout to EM because an error occured while saving a containig sequence. Details: $($_.Exception.Message)" } } # Add sequence-ID to Api Object $EMRolloutplan.EMApiRolloutplan.Sequences.Add($s.Id) } # Create the updateflag which is used to notify that the folder is newly created $UpdateFlag = New-Object -TypeName Matrix42.EM.Contract.Container.v2.UpdateFlag "New" # Save the sequence to EM Add-KabompoLogLine -Message "Write EMRolloutplan with status ""New"" to EM-Database." -Component Save-EMApiRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Status = $EMConnection.EMApiConnection.RolloutPlan_Save($UpdateFlag, $EMRolloutplan.EMApiRolloutplan) # Give feedback about the result. If failed raise an exception if ($Status.Type -eq "Success") { $EMRolloutplan.Id = $Status.ID $EMRolloutplan.EMApiRolloutplan.ID = $Status.ID Add-KabompoLogLine -Message "Successful written rolloutplan to EM-Database with ID ""$($EMRolloutplan.Id)""." -Component Save-EMApiRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose return $EMRolloutplan.EMApiRolloutplan.ID } else { $message = "{0} {1}" -f $Status.Message, $Status.SystemMessage Add-KabompoLogLine -Message "$message." -Component Save-EMApiRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose throw $message } } function Remove-EMApiRolloutplan { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] $EMRolloutplan ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Using EM-Api to delete EMRolloutplan from EM Database" -Component Remove-EMApiRolloutplan -Type 1 -LogLevel 0 -Verbose:$DoVerbose $result = $EMConnection.EMApiConnection.Rolloutplan_Delete($EMRolloutplan.Id) if($result.Type -eq "Failed") { throw "Failed to remove rolloutplan from database. Details: $($result.SystemMessage)" } Add-KabompoLogLine -Message "Successful removed rolloutplan with ID ""$($EMRolloutplan.Id)"" from EM-Database." -Component Remove-EMApiRolloutplan -Type 1 -LogLevel 0 -Verbose:$DoVerbose } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzB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G5hN+Di1v0ZAyGO6qMDMAmXdQlWmtU2UD9feJlcmZa3Y+vdjwjfbLro # S56SO5ChxGkN/CeeaPo4+Pt/ln/DK7aLx9fXCL/SbiDKSiAHsvY6yyh03PpS5d/r # 9TvTvNLcx0Wqq+hz37TwcU+DAa4kKg1cqRcxUAkwgYl1RvPNts1b1Q16QowYJwiX # PfSXxyHWuW9bb6dxGH8hVnUrMbrbCu6Tu0cEKtIyxvqCEM8RsNRbCWuwDuh+WH2x # krHQKiyKyUM= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/RunBuild.ps1
RunBuild.ps1
Param ( [Parameter(Mandatory=$false, Position=0)] [ValidateNotNullorEmpty()] $TargetDir="C:\BUILD\EMPSSDK" ) function Work { foreach($File in $FileList) { Write-Host "Copy File $File" Copy-Item -Path "$($PSScriptRoot)\$File" -Destination "$TargetDir\$File" Write-Host "Sign File $File" $result = Set-AuthenticodeSignature -Certificate $cert -FilePath "$TargetDir\$File" } } try { $FileList = @() $FileList += ,"EMPSSDK.psd1" $FileList += ,"EMPSSDK.psm1" $FileList += ,"Matrix42.EMPSSDK.EMActions.ps1" $FileList += ,"Matrix42.EMPSSDK.EMActions.Helper.ps1" $FileList += ,"Matrix42.EMPSSDK.EMBase.ps1" $FileList += ,"Matrix42.EMPSSDK.EMBase.Helper.ps1" $FileList += ,"Matrix42.EMPSSDK.EMComputer.ps1" $FileList += ,"Matrix42.EMPSSDK.EMComputer.Helper.ps1" $FileList += ,"Matrix42.EMPSSDK.EMConditions.ps1" $FileList += ,"Matrix42.EMPSSDK.EMConditions.Helper.ps1" $FileList += ,"Matrix42.EMPSSDK.EMFolder.ps1" $FileList += ,"Matrix42.EMPSSDK.EMFolder.Helper.ps1" $FileList += ,"Matrix42.EMPSSDK.EMReleasegroups.ps1" $FileList += ,"Matrix42.EMPSSDK.EMReleasegroups.Helper.ps1" $FileList += ,"Matrix42.EMPSSDK.EMRolloutplans.ps1" $FileList += ,"Matrix42.EMPSSDK.EMRolloutplans.Helper.ps1" $FileList += ,"Matrix42.EMPSSDK.EMSequences.ps1" $FileList += ,"Matrix42.EMPSSDK.EMSequences.Helper.ps1" $FileList += ,"Matrix42.EMPSSDK.EMUser.ps1" $FileList += ,"Matrix42.EMPSSDK.EMUser.Helper.ps1" $FileList += ,"Matrix42.EMPSSDK.Logging.ps1" $FileList += ,"Matrix42.EMPSSDK.SystemVariables.ps1" $FileList += ,"Matrix42.EMPSSDK.Variables.ps1" if(Test-Path $TargetDir) { Remove-Item -Path $TargetDir -Recurse -Force } $Directory = New-Item $TargetDir -ItemType Directory Write-Host "Get certificate from file" #$cert = Get-PfxCertificate -FilePath "$($PSScriptRoot)\matrix42ag.pfx" $path = "$($PSScriptRoot)\matrix42ag.pfx" $pass = "Emp1rum" $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($path,$pass) Write-Host "Copy ""ReleaseNotes.txt"" without certification" Copy-Item -Path "$($PSScriptRoot)\ReleaseNotes.txt" -Destination "$TargetDir\ReleaseNotes.txt" Write-Host "Copy ""Matrix42.EM.Sdk.dll"" without certification" Copy-Item -Path "$($PSScriptRoot)\Matrix42.EM.Sdk.dll" -Destination "$TargetDir\Matrix42.EM.Sdk.dll" Write-Host "Copy ""Matrix42.EM.Contract.dll"" without certification" Copy-Item -Path "$($PSScriptRoot)\Matrix42.EM.Contract.dll" -Destination "$TargetDir\Matrix42.EM.Contract.dll" Work } catch { Write-Host "Something went wrong" Write-Host $_.Exception }
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMUser.Helper.ps1
Matrix42.EMPSSDK.EMUser.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Users # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- #EMUser (PSObject) function New-EMUserObject { Param ( [int]$Id, [string]$Account, [string]$AccountType, [string]$FirstName, [string]$LastName, [string]$Department, [string]$DisplayName, [string]$EMail, [bool]$Archived, [string]$Language, [bool]$Animations, $EMApiUser ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Create the object $o = New-Object -TypeName PSCustomObject Add-KabompoLogLine -Message "Start creating a local EMUser-Object" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Id: $Id" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Account: $Account" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...AccountType: $AccountType" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...FirstName: $FirstName" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...LastName: $LastName" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Department: $Department" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...DisplayName: $DisplayName" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...EMail: $EMail" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Archived: $Archived" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Language: $Language" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Animations: $Animations" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Id" -Value $Id Add-Member -InputObject $o -MemberType NoteProperty -Name "Account" -Value $Account Add-Member -InputObject $o -MemberType NoteProperty -Name "AccountType" -Value $AccountType Add-Member -InputObject $o -MemberType NoteProperty -Name "FirstName" -Value $FirstName Add-Member -InputObject $o -MemberType NoteProperty -Name "LastName" -Value $LastName Add-Member -InputObject $o -MemberType NoteProperty -Name "Department" -Value $Department Add-Member -InputObject $o -MemberType NoteProperty -Name "DisplayName" -Value $DisplayName Add-Member -InputObject $o -MemberType NoteProperty -Name "EMail" -Value $EMail Add-Member -InputObject $o -MemberType NoteProperty -Name "Archived" -Value $Archived Add-Member -InputObject $o -MemberType NoteProperty -Name "Language" -Value $Language Add-Member -InputObject $o -MemberType NoteProperty -Name "Animations" -Value $Animations Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiUser" -Value $EMApiUser # Format the object Add-KabompoLogLine -Message "Add properties ""Account"",""AccountType"",""FirstName"",""LastName"",""Department"",""DisplayName"",""EMail"",""Archived"",""Language"",""Animations""" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $VisibleProperties = @("Account","AccountType","FirstName","LastName","Department","DisplayName","EMail","Archived","Language","Animations") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o -Verbose:$DoVerbose # Specify the type name $o.PSObject.TypeNames.Clear() Add-KabompoLogLine -Message "Add type name ""EMUser""" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $o.PSObject.TypeNames.Add("EMUser") Add-KabompoLogLine -Message "Finished creating a local EMUser-Object" -Component New-EMUserObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMUserObject -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMFolder=$null throw $_.Exception } } function Get-EMApiUser { Param ( [Parameter(Mandatory=$true,Position=0)] [string]$UserName ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMApiUser = $EMConnection.EMApiConnection.Account_Load($UserName) return $EMApiUser } function Test-EMUser { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] [string]$UserName=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start testing user." -Component Test-EMUser -Type 1 -LogLevel 2 -Verbose:$DoVerbose $ret = $false $global:logIndention++ $EMUserToTest = Get-EMUser -EMConnection $EMConnection -UserName $UserName -Verbose:$DoVerbose $global:logIndention-- if($EMUserToTest -eq $null) { Add-KabompoLogLine -Message "The given User ""$UserName"" doesn't exist on EM-Server ""$($EMConnection.Server)""." -Component Test-EMUser -Type 1 -LogLevel 2 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "The given User ""$UserName"" was found." -Component Test-EMUser -Type 1 -LogLevel 1 -Verbose:$DoVerbose $ret = $true } Add-KabompoLogLine -Message "Finished testing user. Result = $ret." -Component Test-EMUser -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $ret } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Test-EMUser -Type 3 -Verbose:$DoVerbose throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUkRdmb665zkMZTBZ6HGpZRdEj # uTugggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0M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oRX9ak # JYmbBWsvtMkBTCd7C6wZBSKgYBU/2sn7TUyP+3Jnd/0nlMe6NQ6ISf6N/SivShK9 # DbOXBd5EDBX6NisD3MFQAfGhEV0U5eK9J0tUviuEXg+mw3QFCu+Xw4kisR93873N # Q9TxTKk/tYuEr2Ty0BQhMYICNTCCAjECAQEwgZMwfzELMAkGA1UEBhMCVVMxHTAb # BgNVBAoTFFN5bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FFSGFNfk4ueSIyMFt/rFdHI9jLEAMA0GCSqGSIb3DQEBAQUABIIBALpdk9iOYhfe # CHvnERxnzDPBK3BORI7V5d/YA3D1hIGGW3Zs5EMZQNtrAhLo5FFqkfNunUwry/xr # SDd78v+ONat3nWK/MeUub2GP2LH4k2oxAxPBqmRwSXXs2hBljaVZltVkr39fX6dB # zSTDaqx3sNsW+Ql9Moo6zKc/btQ3RXkO7WKdj93XRPjEsYhAVtn2YgNSrpwTtHaY # pk9oUiuD8NpOtQXuV2eMdpqb7FpF0x+/jpd3Wq5rUaHmwyZR9Dpx0y4PLnUffPuf # R/MTzztj16a0oF0Wg45v+xsgIW40mSQeKsiM8M4axWHh0AQuLNtlNj6vTqAvsPMb # fWwR6DdXKF8= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMSCCMTask.ps1
Matrix42.EMPSSDK.EMSCCMTask.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Sequences # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMSCCMTask.Helper.ps1" function New-EMSCCMTask { <# .SYNOPSIS Creates a local SCCM Task object which you can edit and transfer to the "Matrix42 Enterprise Manager for SCCM" (EM) via the WebService Interface. .DESCRIPTION Creates a local SCCM Task object which you can edit and transfer to the "Matrix42 Enterprise Manager for SCCM" (EM) via the WebService Interface. Use the Save-EMSCCMTask method to transfer the information to the EM-Server. .EXAMPLE New-EMSCCMTask -Taskname "Testtask 01" -SCCMId "SCCMId/DeploymentTypeId" -PackageType Application -RolloutType PushRollout -TargetMode Device -Owner "emppsdk" -Threshold 80 -Purpose Available -Verbose .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [string]$Taskname, [Parameter(Mandatory=$true,Position=1)] [string]$SCCMId, [Parameter(Mandatory=$true,Position=2)] [ValidateSet('Application','Package')] [string]$PackageType, [Parameter(Mandatory=$true,Position=3)] [ValidateSet('PushRollout','MassRollout')] [string]$RolloutType, [Parameter(Mandatory=$true,Position=4)] [ValidateSet('Device','User')] [string]$TargetMode, [Parameter(Mandatory=$false,Position=5)] [string]$Owner, [Parameter(Mandatory=$false,Position=6)] [int]$Threshold, [Parameter(Mandatory=$true,Position=7)] [ValidateSet('Available','Required')] [string]$Purpose, [Parameter(Mandatory=$false,Position=8)] [bool]$Predeploy, [Parameter(Mandatory=$false,Position=9)] [bool]$WakeOnLan, [Parameter(Mandatory=$false,Position=10)] [bool]$MeteredInternet, [Parameter(Mandatory=$false,Position=11)] [ValidateSet('ShowTaskAndAllInfos','ShowTaskAndOnlyReboot','Hide')] [string]$UserExperience = 'ShowTaskAndAllInfos', [Parameter(Mandatory=$false,Position=12)] [bool]$Enabled = $true ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a local EMSCCMTask object" -Component New-EMSCCMTask -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Create sequence object $EMApiSCCMTask = New-Object -TypeName Matrix42.EM.Contract.Container.v2.Sccm_Task $EMApiSCCMTask.Name = $Taskname if($PackageType -eq "Package") { $EMApiSCCMTask.PackageID = $SCCMId } else { $EMApiSCCMTask.ID_Application = $SCCMId } if($RolloutType -eq "MassRollout") { $EMApiSCCMTask.Type = "Rollout" } else { $EMApiSCCMTask.Type = "Push" } $EMApiSCCMTask.Mode = $TargetMode # Will be set during the "Save" operation # $EMApiSCCMTask.Delegator = $EMApiSCCMTask.Account = $Owner $EMApiSCCMTask.ThresHold = $Threshold $EMApiSCCMTask.OfferType = $Purpose $EMApiSCCMTask.PreDeploy = $Predeploy $EMApiSCCMTask.WakeOnLan = $WakeOnLan $EMApiSCCMTask.MeteredInternet = $MeteredInternet $EMApiSCCMTask.UserUIExperiences = $UserExperience $EMApiSCCMTask.Enabled = $Enabled # Create EM-PS Object Add-KabompoLogLine -Message "Create local PS object" -Component New-EMSCCMTask -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMSCCMTask = New-EMSCCMTaskObject -Taskname $Taskname -SCCMId $SCCMId -PackageType $PackageType -RolloutType $RolloutType -Archived $false -TargetMode $TargetMode -CreatedBy $conn.Account -Owner $Owner -Threshold $Threshold -Purpose $Purpose -Predeploy $Predeploy -WakeOnLan $WakeOnLan -MeteredInternet $MeteredInternet -UserExperience $UserExperience -Enabled $Enabled -EmApiSCCMTask $EMApiSCCMTask -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Finished creating a local EMSCCMTask object with name $Taskname" -Component New-EMSCCMTask -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMSCCMTask } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMComputer -Type 3 -Verbose:$DoVerbose $EMComputer=$null throw $_.Exception } } function Get-EMSCCMTask { <# .SYNOPSIS Load a SCCM Task from the EM-Database. .DESCRIPTION Load a SCCM Task from the EM-Database based on the ID of the Task .EXAMPLE Get-EMSCCMTask -EMConnection $conn -SCCMTaskId 123 .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] $SCCMTaskId=$null ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start loading a SCCM Task from EM." -Component Get-EMSCCMTask -Type 1 -LogLevel 2 -Verbose:$DoVerbose # If SCCM Task id is given, lets directly query for it Add-KabompoLogLine -Message "The SCCM Task ID ""$SCCMTaskId"" is given. Try to find the SCCM-task." -Component Get-EMSCCMTask -Type 1 -LogLevel 1 -Verbose:$DoVerbose $result = Get-EMApiSCCMTaskLoad -EMConnection $EMConnection -SCCMTaskId $SCCMTaskId # No return if($result -eq $null) { Add-KabompoLogLine -Message "No SCCM Tasks received" -Component Get-EMSCCMTask -Type 1 -LogLevel 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "Successful read out SCCM Task with ID ""$($result.ID)""" -Component Get-EMSCCMTask -Type 1 -LogLevel 1 -Verbose:$DoVerbose if(!([string]::IsNullOrEmpty($result.ID_Application))) { $PackageType = "Application" $SCCMId = $result.ID_Application } else { $PackageType = "Package" $SCCMId = $result.PackageID } if($result.Type -ieq "Push") { $RolloutType = "PushRollout" } else { $RolloutType = "MassRollout" } $global:logIndention++ $EMSCCMTask = New-EMSCCMTaskObject -Id $result.ID -Taskname $result.Name -SCCMId $SCCMId -PackageType $PackageType -RolloutType $RolloutType -Archived $result.Archived -TargetMode $result.Mode -CreatedBy $result.Delegator -Owner $result.Account -Threshold $result.ThresHold -Purpose $result.OfferType -Predeploy $result.Predeploy -WakeOnLan $result.WakeOnLan -MeteredInternet $result.MeteredInternet -UserUIExperiences $result.UserUIExperiences -Enabled $result.Enabled -Status $result.StatusTask -IsSuccessful $result.IsSucessfull -IsFailed $result.IsFailed -EMApiSCCMTask $result $global:logIndention-- } Add-KabompoLogLine -Message "Finished loading SCCM-Task from EM." -Component Get-EMSCCMTask -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return the SCCM Task return $EMSCCMTask } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Get-EMSCCMTask -Type 3 -Verbose:$DoVerbose $EMSCCMTask=$null $global:logIndention = $localIndent throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUytn5bEA7QVEGQOLbWr3SeqgH # aFSgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw # ggEKAoIBAQDHZNuFnBatHdyRnMUJ2Y1P6k49MjD04t9S7ukWj8upP/B6wPRYzzQf # 6QVMPKzMhNTPfIXaIEzi/jh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zdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FE1FUQxwMVtb8yeYpu0dFx52hGGsMA0GCSqGSIb3DQEBAQUABIIBABq6t5NdPEbD # hAJ1pjNuQH65BGgC6m5sg1Wv4ZID9C3QUNXcJhgZaR8xdLyGE4d5/l0ApHE4V9if # zvqeDnRRO8TrMsuJ4Y5DfMTr4Gg/XiZpUdY9jCiDMIfwDszSen61Avys72gNK6oJ # DjPpVW5DFEihawBwrWvhp0RrJ8uQNG5ErF4JuNCEOzM2lXSvKAiS+TZM2IS5ufeh # h6Zrm5+rydPcIs/w01Kz3T3gVrpjwFogIt4aussKv4wUF8xklyuhpg/X3kFAipzX # +TqIwt3nGLwXcJLGGZ1XxBIn1aJQpzbUD6wp0W6LpdYVpG7zJBfTEV446BdbNb5R # SvhA+mNS9NU= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMConditions.Helper.ps1
Matrix42.EMPSSDK.EMConditions.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Conditions # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- #EMCondition (PSObject) function New-EMConditionObject { Param ( [int]$Id, [string]$ConditionType, [string]$Icon, [string]$DeConditionName, [string]$EnConditionName, [bool]$ConditionResult = $true, [string]$BracketLeft, [string]$BracketRight, [int]$SortKey, [int]$Check, [Matrix42.EM.Contract.Container.v2.Sequence+Action+Condition]$EMApiCondition ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $m = "Create a new EM{0}Condition with following parameter:" -f $ConditionType Add-KabompoLogLine -Message $m -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ConditionName: $DeConditionName" -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ConditionName: $EnConditionName" -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ConditionResult: $ConditionResult" -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...BracketLeft: $BracketLeft" -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...BracketRight: $BracketRight" -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Connector: $Connector" -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SortKey: $SortKey" -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Check: $Check" -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Create the object $o = New-Object -TypeName PSCustomObject # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Id" -Value $Id Add-Member -InputObject $o -MemberType NoteProperty -Name "ConditionType" -Value $ConditionType Add-Member -InputObject $o -MemberType NoteProperty -Name "Icon" -Value $Icon Add-Member -InputObject $o -MemberType NoteProperty -Name "DeConditionName" -Value $DeConditionName Add-Member -InputObject $o -MemberType NoteProperty -Name "EnConditionName" -Value $EnConditionName Add-Member -InputObject $o -MemberType NoteProperty -Name "ConditionResult" -Value $ConditionResult Add-Member -InputObject $o -MemberType NoteProperty -Name "BracketLeft" -Value $BracketLeft Add-Member -InputObject $o -MemberType NoteProperty -Name "BracketRight" -Value $BracketRight Add-Member -InputObject $o -MemberType NoteProperty -Name "SortKey" -Value $SortKey Add-Member -InputObject $o -MemberType NoteProperty -Name "Check" -Value $Check Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiCondition" -Value $EMApiCondition # Format the object $VisibleProperties = @("DeConditionName","EnConditionName","ConditionType","Icon","ConditionResult","BracketLeft","BracketRight","SortKey","Check") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o -Verbose:$DoVerbose # Specify the type name $o.PSObject.TypeNames.Clear() $o.PSObject.TypeNames.Add("EMCondition") Add-KabompoLogLine -Message "Successful created EMCondition-Object" -Component New-EMConditionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } function New-EMApiCondition { Param ( [Parameter(Mandatory=$false,Position=1)] [ValidateSet("Inventory","Service","Registry","Account","File","Folder","Process","EnvironmentVar",<#"None", "Internal"#> "EmVar")] [string]$ConditionType, [Parameter(Mandatory=$false,Position=2)] [string[]]$Parameter=$null, [Parameter(Mandatory=$false,Position=3)] [bool]$ConditionResult=$true, [Parameter(Mandatory=$false,Position=4)] [ValidateSet("None","Single","Double")] [string]$BracketLeft="None", [Parameter(Mandatory=$false,Position=5)] [ValidateSet("None","Single","Double")] [string]$BracketRight="None", [Parameter(Mandatory=$false,Position=6)] [ValidateSet("None","AND","OR")] [string]$Connector="None", [Parameter(Mandatory=$false,Position=7)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=8)] [string]$DeDisplayName= $null, [Parameter(Mandatory=$false,Position=9)] [string]$EnDisplayName= $null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating an EM-Api-Condition" -Component New-EMApiCondition -Type 1 -LogLevel 0 -Verbose:$DoVerbose if ([string]::IsNullOrEmpty($DeDisplayName) -and [string]::IsNullOrEmpty($EnDisplayName)) { throw "At least one of the display names for condition of type ""$ConditionType"" must be given" } if ($Parameter -eq $null) { throw "Parameters missing for condition of type ""$ConditionType""" } if ($Parameter.Count -ne $global:ConditionParameters[$ConditionType].Count) { throw "Invalid parameter count for action of type ""$($ConditionType)"". ""$($global:ActionParameters[$ConditionType].Count)"" parameters expected, but just ""$($Parameter.Count)"" given." } Add-KabompoLogLine -Message "Create API Condition and add properties..." -Component New-EMApiCondition -Type 1 -LogLevel 0 -Verbose:$DoVerbose $EMApiCondition=New-Object -TypeName Matrix42.EM.Contract.Container.v2.Sequence+Action+Condition $EMApiCondition.Type= $ConditionType $EMApiCondition.Parameter.AddRange($Parameter) $EMApiCondition.ConditionResult = $ConditionResult $EMApiCondition.De_DisplayName= $DeDisplayName $EMApiCondition.En_DisplayName= $EnDisplayName $EMApiCondition.SortKey=$SortKey $EMApiCondition.Connector= $Connector $EMApiCondition.BracketLeft= $BracketLeft $EMApiCondition.BracketRight= $BracketRight $EMApiCondition.Icon= $global:ConditionDefaultIcons[$ConditionType] Add-KabompoLogLine -Message "Finished creating an EM-API-Condition" -Component New-EMApiCondition -Type 1 -LogLevel 0 -Verbose:$DoVerbose return $EMApiCondition } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMApiCondition -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMApiCondition = $null throw $_.Exception } } function Convert-EMApiConditionToEMCondition { Param ( [Parameter(Mandatory=$true,Position=1)] $EMApiCondition ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMCondition = $null Add-KabompoLogLine -Message "Start converting an API Condition to an EM Condition" -Component Convert-EMApiConditionToEMCondition -Type 1 -LogLevel 0 -Verbose:$DoVerbose if($EMApiCondition.Type -eq "File") { Add-KabompoLogLine -Message "Detected a file condition" -Component Convert-EMApiConditionToEMCondition -Type 1 -LogLevel 0 -Verbose:$DoVerbose $global:logIndention++ $EMCondition = New-EMFileCondition -FileName $EMApiCondition.Parameter[0] -FileMustExist $EMApiCondition.ConditionResult -BracketLeft $EMApiCondition.BracketLeft -BracketRight $EMApiCondition.BracketRight -Connector $EMApiCondition.Connector -SortKey $EMApiCondition.Sortkey -DeDisplayName $EMApiCondition.De_DisplayName -EnDisplayName $EMApiCondition.En_DisplayName -EMApiCondition $EMApiCondition -Verbose:$DoVerbose $global:logIndention-- } else { throw "Given conditiontype currently not supported" } Add-KabompoLogLine -Message "Finished converting an API Condition to an EM Condition" -Component Convert-EMApiConditionToEMCondition -Type 1 -LogLevel 0 -Verbose:$DoVerbose return $EMCondition } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Convert-EMApiConditionToEMCondition -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMCondition=$null throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUgUuzdOlpTxjeds6d3zW2NCH8 # k0KgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw # ggEKAoIBAQDHZNuFnBatHdyRnMUJ2Y1P6k49MjD04t9S7ukWj8upP/B6wPRYz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wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FKaH0KX39RVbeYkzeU6KGvmv9T7OMA0GCSqGSIb3DQEBAQUABIIBAIa0cbtJPmCo # IVF/YRowCKyP3RX00onaAWWZb/92OGj4LvEKrXhBN9qBoFXlbHH2wygt5tA41Ccf # +3K/4wIBwfU8YSGtfo7aCO+ZDw1HFB4phaa+4lD1l1jooR6vUub12dRBYdl454Qm # JZmlKciH1Z2+njYGWAc+M4KaCFZswiacn/6FCVdjERMauOAqL9v+ECwEnWiHzTN2 # 2A9BmmdgqZ/1MsrEjKlIRoUhTPxHKUqNDM4dddUkeVE8xWK6lLN91ciXH8jM3MDz # OXr6lJ6tyN3lIXT5oEBFmb40a82sLxB0pxi1llHRtAmCiOe7YUQmc/MdBpvzz8tc # siMnVb5KOFM= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMReleasegroups.Helper.ps1
Matrix42.EMPSSDK.EMReleasegroups.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Releasegroups # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- #EMRolloutplan (PSObject) function New-EMReleasegroupObject { Param ( [int]$Id, [string]$Name, $EMApiReleasegroup ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Create the object $o = New-Object -TypeName PSCustomObject Add-KabompoLogLine -Message "Start creating a local EMReleasegroup Object" -Component New-EMReleasegroupObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Id: $Id" -Component New-EMReleasegroupObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Name: $Name" -Component New-EMReleasegroupObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Id" -Value $Id Add-Member -InputObject $o -MemberType NoteProperty -Name "Name" -Value $Name Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiReleasegroup" -Value $EMApiReleasegroup # Format the object Add-KabompoLogLine -Message "Add properties ""Id"", ""Name""" -Component New-EMReleasegroupObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $VisibleProperties = @("Id", "Name") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o # Specify the type name $o.PSObject.TypeNames.Clear() Add-KabompoLogLine -Message "Add type name ""EMReleasegroup""" -Component New-EMReleasegroupObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $o.PSObject.TypeNames.Add("EMReleasegroup") Add-KabompoLogLine -Message "Finished creating a local EMReleasegroup Object" -Component New-EMReleasegroupObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMRolloutplanObject -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMRolloutplan=$null throw $_.Exception } } function Get-EMApiReleasegroupSearch { Param ( [Parameter(Mandatory=$true,Position=0)] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [string]$ReleasegroupName ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMApiReleasegroup = @() try { $result = $EMConnection.EMApiConnection.ReleaseGroup_Load($false) } catch { } foreach($r in $result) { if($r.Releasegroups.Count -eq 0) { continue } elseif($r.Releasegroups.Count -ge 1) { foreach($rg in $r.Releasegroups.Values) { if($rg.Name -like $ReleasegroupName) {$EMApiReleasegroup += ,$rg } } } } return $EMApiReleasegroup } function Get-EMApiReleasegroupLoad { Param ( [Parameter(Mandatory=$true,Position=0)] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [int]$ReleasegroupId ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMApiReleasegroup = $EMConnection.EMApiConnection.ReleaseGroup_Load($false, $ReleasegroupId) return $EMApiReleasegroup } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU3xaYuHvw7FV8bVEVKHxSqBPV # UoigggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw # ggEKAoIBAQDHZNuFnBatHdyRnMUJ2Y1P6k49MjD04t9S7ukWj8upP/B6wPRYzzQf # 6QVMPKzMhNTPfIXaIEzi/jhT0jjwnXC0O9hF2rwTpDRnVOnVJemaqd2XsSDVEBUY # yhH7QZ82Zwi1nnSgo69WL694L3f74ge6bRiRIJ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Q0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FIQQ65TZ87vx16S3dwua5z3C0ET4MA0GCSqGSIb3DQEBAQUABIIBAAlPJI5eghhF # gQ0b1tjmPmJe3NFMENjvF1xVzC66litpCKrLthdnGufOXjw1WKV240h9T1QwCI3G # cA81RR0JNJkXEkT/6bas7uw0qoFKDWev8T4BuHvp8eiFZaU4WtqaTnJwnM4VGRT/ # jQCZI7Qy3I+dy9ZMw0JcZm1bHyb1QEk4vuL8ZFrVCAGsaDa+xQvoKEunqmitKz6/ # MVT4ZxyO52X1Qdf67KplVaqBjoHwPOu1A/7CBPCVtoqVjjJvJAPvpMlhKhqRNCWo # wGhs7XOk9/BgLI2mhxmerAOOjXuob7BWwDsjpmR9dTbv83WZ6iQy+hfBSGaA3eeB # arjdhDC+k4o= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMConditions.ps1
Matrix42.EMPSSDK.EMConditions.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Conditions # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMConditions.Helper.ps1" function New-EMFileCondition { <# .SYNOPSIS Create a new file condition. .DESCRIPTION Create a new file condition which can be used in an EM-Sequence .EXAMPLE New-EMFileCondition -FileName "MyApp.exe" Creates a file condition which checks if a file with name "MyApp.exe" exist. .EXAMPLE New-EMFileCondition -FileName "MyApp.exe" -FileMustExist $False Creates a file condition which checks if a file with name "MyApp.exe" NOT exist. .EXAMPLE New-EMFileCondition -FileName "MyApp.exe" -DeDisplayName "Datei ist vorhanden" -EnDisplayName "File doesn't exist" Creates a file condition which checks if a file with name "MyApp.exe" exist. The condition gets a custom german and eglish name. .EXAMPLE New-EMFileCondition -FileName "MyApp.exe1" -SortKey 0 New-EMFileCondition -FileName "MyApp.exe2" -Connector OR -SortKey 1 WIll create two conditions and will connect them with an OR clause .EXAMPLE New-EMFileCondition -FileName "MyApp.exe1" -BracketLeft Single -BracketRight None -SortKey 0 New-EMFileCondition -FileName "MyApp.exe2" -BracketLeft None -BracketRight Single -Connector OR -SortKey 1 New-EMFileCondition -FileName "MyApp.exe3" -Connector AND -SortKey 0 WIll create three conditions. THe first 2 one will be connected by OR, the second one is connected with an AND clause to the first both. .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=1)] [string]$FileName= $null, [Parameter(Mandatory=$false,Position=2)] [bool]$FileMustExist=$true, [Parameter(Mandatory=$false,Position=3)] [ValidateSet("None","Single","Double")] [string]$BracketLeft="None", [Parameter(Mandatory=$false,Position=4)] [ValidateSet("None","Single","Double")] [string]$BracketRight="None", [Parameter(Mandatory=$false,Position=5)] [ValidateSet("None","AND","OR")] [string]$Connector="None", [Parameter(Mandatory=$false,Position=6)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=7)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=8)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=9)] $EMApiCondition=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Write startup to Logfile Add-KabompoLogLine -Message "Start creating a file condition" -Component New-EMFileCondition -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Check if APICondition is matching with FileCondition is given if($EMApiCondition -ne $null) { if($EMApiCondition.Type -ine "file") { throw "You cannot create an EMFileCondition based on EMApiCondition with type ""$EMApiCondition.Type""" } } # Add FileName to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter $FileName" -Component New-EMFileCondition -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$FileName # Configure english text if([string]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = "File ""{0}"" must exist" -f $FileName } # Configure german text if([string]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = "Datei ""{0}"" muss existieren" -f $FileName } # Create the Object from EM-API if it's not given if($EMApiCondition -eq $null) { Add-KabompoLogLine -Message "Create API object" -Component New-EMFileCondition -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiCondition = New-EMApiCondition -ConditionType "File" -Parameter $Parameters -ConditionResult $FileMustExist -BracketLeft $BracketLeft -BracketRight $BracketRight -Connector $Connector -SortKey $SortKey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -Verbose:$DoVerbose $global:logIndention-- } # Create the EM-Object (will do the logging also) Add-KabompoLogLine -Message "Create PS object from API object" -Component New-EMFileCondition -Type 1 -LogLevel 1 -Verbose:$DoVerbose $EMCondition = New-EMConditionObject -Id $EMApiCondition.ID -ConditionType $EMApiCondition.Type -Icon $EMApiCondition.Icon -DeConditionName $EMApiCondition.De_DisplayName -EnConditionName $EMApiCondition.En_DisplayName -ConditionResult $EMApiCondition.ConditionResult -BracketLeft $EMApiCondition.BracketLeft -BracketRight $EMApiCondition.BracketRight -SortKey $EMApiCondition.SortKey -Check $EMApiCondition.Check -EMApiCondition $EMApiCondition -Verbose:$DoVerbose Add-KabompoLogLine -Message "Add property ""File"" to the PS-Object" -Component New-EMFileCondition -Type 1 -Verbose:$DoVerbose # Add the file property to the EM Object Add-Member -InputObject $EMCondition -MemberType NoteProperty -Name "FileName" -Value $FileName # Add "File" as referenced property type $EMCondition.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("FileName") Add-KabompoLogLine -Message "Finished creating the file condition for file $FileName." -Component New-EMFileCondition -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMCondition } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMFileCondition -Type 3 -Verbose:$DoVerbose $EMCondition=$null throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU5Vw3mA+n1kJKXDmAGAHNT7sP # y0KgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw # ggEKAoIBAQDHZNuFnBatHdyRnMUJ2Y1P6k49MjD04t9S7ukWj8upP/B6wPRYzzQf # 6QVMPKzMhNTPfIXaIEzi/jhT0jjwnXC0O9hF2rwTpDRnVOnVJemaqd2XsSDVEBUY # yhH7QZ82Zwi1nnSgo69WL694L3f74ge6bRiRIJ/IoZawj+74NL/9B93kGKH89sew # VtqPoDwSklJmzc86Qlgw6X/WXenHw8n6k/htEIjkHpiE6iGkDZp1gAPBERIV/qi/ # HyIZpvsO3g9RvcWEDvRvq6ZsIPfAvtlOnVWPrvik96pEDugHKPtvyjuAQtJtxw42 # zsYbB7lQxCo7khjhuZKYrzjv/l79BnC1Ag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XWxKq22ztB+v0vBdOk8EAQMA0GCSqGSIb3DQEBAQUABIIBALp+tQ9++qeN # CsvbDYhES7UIfJJzydyPB1htD/8C9eZofXd5uHMDT8AYeFpLcI5CCq1J2A9+MygI # 3QHVf+WDrX+/I0cEQ3KdEhGP1798T99genmV3eah+tjueXJ66BeKhdZsSxWnhizD # K78fL5vNbh94bD8q/tl57T33Me21IWn0alP2MiUrTBnGPx7pBaa03KRgSoRZ8U0x # 8sDqKJq8zwm4gfb59hreYfndnpL2tZ64qL/2vIraA3SfQYvRLMrrnKNl0WOZeKuR # r2OXyTis6BSIuVtQ4ubxTrIN6zeBuWO0W2NsU8/72U2GcAwDCEWeYrrQtUQK2Z3X # lmO2nCbktk0= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/RunTest.ps1
RunTest.ps1
$FilesToTest = @() $FilesToTest += ,"EMActions" $FilesToTest += ,"EMBase" $FilesToTest += ,"EMComputer" $FilesToTest += ,"EMConditions" $FilesToTest += ,"EMFolder" $FilesToTest += ,"EMReleasegroups" $FilesToTest += ,"EMRolloutplans" $FilesToTest += ,"EMSequences" $FilesToTest += ,"EMUser" $OverallCoverage = 0 # Reset guid to get a "brand-new" connection object $global:TestGuid = $null foreach($File in $FilesToTest) { $TestResult = invoke-pester -Script "$($PSScriptRoot)\Matrix42.EMPSSDK.$File.Tests.ps1" -CodeCoverage "$($PSScriptRoot)\Matrix42.EMPSSDK.$File.ps1" -PassThru -Quiet $FileCodeCoveragePercent = (100 / $TestResult.CodeCoverage.NumberOfCommandsAnalyzed) * $TestResult.CodeCoverage.NumberOfCommandsExecuted $Output = "Code coverage ""$File"": {0:N2}%" -f $FileCodeCoveragePercent Write-Host $Output $OverallCoverage = $OverallCoverage + $FileCodeCoveragePercent } $OverallCodeCoveragePercent = $OverallCoverage / $FilesToTest.Count $Output = "Overall code coverage: {0:N2}%" -f $OverallCodeCoveragePercent Write-Host $Output
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.SystemVariables.ps1
Matrix42.EMPSSDK.SystemVariables.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: System variables that are used internal. Please do not touch. # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- $global:logIndention = 0 #region Define all action icons in a hash table $global:ActionDefaultIcons = @{} $global:ActionDefaultIcons.Add("Software", "Software.png") $global:ActionDefaultIcons.Add("Download", "Download.png") $global:ActionDefaultIcons.Add("Restart", "Reboot.png") $global:ActionDefaultIcons.Add("Service", "Services.png") $global:ActionDefaultIcons.Add("Account", "UserEdit.png") $global:ActionDefaultIcons.Add("Registry", "Registry.png") $global:ActionDefaultIcons.Add("File", "File.png") $global:ActionDefaultIcons.Add("Folder", "Folder.png") $global:ActionDefaultIcons.Add("Process", "Process.png") $global:ActionDefaultIcons.Add("Monitoring", "Monitoring.png") $global:ActionDefaultIcons.Add("EnvironmentVar", "EnvironmentVariable.png") $global:ActionDefaultIcons.Add("Info", "Information.png") $global:ActionDefaultIcons.Add("Application", "Application.png") #endregion #region Define all condition icons in a hash table $global:ConditionDefaultIcons = @{} $global:ConditionDefaultIcons.Add("Inventory", "Wmi.png") $global:ConditionDefaultIcons.Add("Service", "Services.png") $global:ConditionDefaultIcons.Add("Registry", "Registry.png") $global:ConditionDefaultIcons.Add("Account", "User.png") $global:ConditionDefaultIcons.Add("File", "File.png") $global:ConditionDefaultIcons.Add("Folder", "Folder.png") $global:ConditionDefaultIcons.Add("Process", "Process.png") $global:ConditionDefaultIcons.Add("EnvironmentVar", "EnvironmentVariable.png") #$global:ConditionDefaultIcons.Add("None", $null) #internal $global:ConditionDefaultIcons.Add("EmVar", "Variable.png") #endregion #region Define all available action parameters in a hash table $global:ActionParameters = @{} $global:ActionParameters.Add("Software", ("Package Id", "Program name", "[optional] EM Arguments", "Mode (Install-Uninstall-Patch-Update)")) $global:ActionParameters.Add("Download", ("Package Id", "Targe path for download", "Name of package")) $global:ActionParameters.Add("Restart", ("Mode (Reboot-Shutdown)", "Handle programs (Wait-Force)", "[optional] User options (Force-Moveable)", "Waiting time (minutes)", "User info text (DE)", "User info text (EN)")) $global:ActionParameters.Add("Service", ("Name of service", "Mode(Start-Stop)")) $global:ActionParameters.Add("Account", ("Object", "[optional] Object type", "Target(Local-Global)", "[Local] Local group", "[Global] Global group", "[Global, optional] Global group type", "[Global] Access accout", "[Global, optional] Access accout type", "[Global] Encrypted password", "Mode (Add-Remove)")) $global:ActionParameters.Add("Registry", ("Mode (Create-Remove)", "Key", "[optional] Entry name", "[Create and Entry name given] Value type (String-Binary-DWord-MultiString-ExpandString)", "[Create and Entry name given] Value")) $global:ActionParameters.Add("File", ("Mode (Create-Remove)", "File name", "[optional] File content")) $global:ActionParameters.Add("Folder", ("Mode (Create-Remove)", "Folder name")) $global:ActionParameters.Add("Process", ("Mode (Start-Kill)", "Path to executable", "[optional] Arguments to process", "Display mode (Admin-User)", "Context mode (System-User)", "Wait for exit? (true-false)", "Maximum run time (minutes)")) $global:ActionParameters.Add("Monitoring", ("Time for auto close (minutes, 0: no close!)", "[multiple possible] Process to observe (`"<Application name>|<Process name>`")")) $global:ActionParameters.Add("EnvironmentVar", ("Variable name", "Mode (Create-Remove)", "Target (Process-User-Machine)", "Value type (LastExitCode-OwnValue)", "[OwnValue] Value for variable")) $global:ActionParameters.Add("Info", ("Name (DE)", "Name (EN)", "Description (DE)", "Description (EN)", "Width of window", "Height of window", "Time for auto close (minutes, 0 and 999: no close!)", "Task mode (Continue-Wait)", "User mode (Close-CloseDenied)")) $global:ActionParameters.Add("Application", ("Application Id", "Mode (Install-Uninstall)", "[optional] EM Arguments")) #$global:ActionParameters.Add("PreDownload", 2) #internal #$global:ActionParameters.Add("Verify", 2) #internal #$global:ActionParameters.Add("UserProcess", 1) #internal #$global:ActionParameters.Add("GuiWindowSchedule", 1) #internal #$global:ActionParameters.Add("GuiWindowExecute", 1) #internal #$global:ActionParameters.Add("TaskStart", 1) #internal #$global:ActionParameters.Add("TaskFinish", 1) #internal #$global:ActionParameters.Add("None", 0) #internal #$global:ActionParameters.Add("TaskReminder", 0) #internal #endregion #region Define all available condition parameters in a hash table $global:ConditionParameters = @{} $global:ConditionParameters.Add("Inventory", ("Id of element", "Value to check", "Operator (`"=`"-`"like`"-`">`"-`"<`"-`">=`"-`"<=`")", "[multiple possible - pair with next] Namespace", "[multiple possible - pair with previous] WMI query")) $global:ConditionParameters.Add("Service", ("Service name", "Mode (Exists-Started)")) $global:ConditionParameters.Add("Registry", ("Mode (KeyExists-EntrieExists-ValueCompare)", "Key", "[EntrieExists or ValueCompare] Entry name", "[ValueCompare] Value")) $global:ConditionParameters.Add("Account", ("Domain", "Account", "[currently unused] Type(Account)", "Group")) $global:ConditionParameters.Add("File", ("File name")) $global:ConditionParameters.Add("Folder", ("Folder name")) $global:ConditionParameters.Add("Process", ("Process name (example: `"winword.exe`")")) $global:ConditionParameters.Add("EnvironmentVar", ("Mode (Exist-Value)", "Variable name", "[Value] Value of variable")) #$global:ConditionParameters.Add("None", $null) #internal $global:ConditionParameters.Add("EmVar", ("Variable name", "Variable value")) #endregion # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU/8iQqXQjZ0OOxcKgPaXvhZQq # ldCgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2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fzHaI+7ofZpn+kVqU/rYQuKd58vKiqoz0EAeq6k6IOUCIpF0yH5DoRX9ak # JYmbBWsvtMkBTCd7C6wZBSKgYBU/2sn7TUyP+3Jnd/0nlMe6NQ6ISf6N/SivShK9 # DbOXBd5EDBX6NisD3MFQAfGhEV0U5eK9J0tUviuEXg+mw3QFCu+Xw4kisR93873N # Q9TxTKk/tYuEr2Ty0BQhMYICNTCCAjECAQEwgZMwfzELMAkGA1UEBhMCVVMxHTAb # BgNVBAoTFFN5bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FA2pqCCKchOtMyJXkZyPqGTFH83CMA0GCSqGSIb3DQEBAQUABIIBAA52wwzKurFa # +ZQdCI9AiBcU1c82+tLZJT2er1tBnnfanjmjDJbuY6PX+EIIq1lZb69RGUbHWjSo # rIFpAPfIyf2UVLXx53UG7xIuC5lEGE2S4sfh/+QRjqm/EF70gX/RcziZQjWsgf6a # X4Rjx0AJXZN61mEiiuizTkd2OVMU+UyX3sprPhphCE9gf+2KHFDarR0k4rTYtTNr # hx3louGr54diwB79TJ56S7w3+onrgpEfo+5BH1N2hXq+LChPkLsJkuj48dy/VYtP # Tr85eJmT7U+4F4cn0Tz7rL+g+4QLULx2iqQeSJqVZys9wsameHlqykkzyaQo4qNu # gz0Kx57O1y4= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMActions.ps1
Matrix42.EMPSSDK.EMActions.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Actions # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMActions.Helper.ps1" function New-EMProcessAction { <# .SYNOPSIS Creates a local process-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local process-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMProcessAction -ProcessName notepad.exe -ProcessActionType Start Will start notepad. .EXAMPLE New-EMProcessAction -ProcessName notepad.exe -ProcessActionType Start -Arguments "c:\test.txt" Will start notepad and open the file "c:\test.txt". .EXAMPLE New-EMProcessAction -ProcessName cmd.exe -ProcessActionType Start -Arguments "/c rd c:\test\empssdk /s /q" -StartProcessVisible Invisible Will delete the folder c:\test\empssdk via the command shell without showing the cmd window. .EXAMPLE New-EMProcessAction -ProcessName cmd.exe -ProcessActionType Start -Arguments "/c rd c:\test\empssdk /s /q" -StartProcessVisible Invisible -Context User Will delete the folder c:\test\empssdk via the command shell without showing the cmd window. In this case the EMAgent is using the user context to run the process (System is default). .EXAMPLE New-EMProcessAction -ProcessName cmd.exe -ProcessActionType Start -Arguments "/c rd c:\test\empssdk /s /q" -WaitForEnd 1 Will delete the folder c:\test\empssdk via the command shell without showing the cmd window. The EM-Agent will wait until he starts the next action. .EXAMPLE New-EMProcessAction -ProcessName cmd.exe -ProcessActionType Start -Arguments "/c rd c:\test\empssdk /s /q" -WaitForEnd 1 -MaxRunTime 10 -ActionOnErrorResumeNext 1 Will delete the folder c:\test\empssdk via the command shell without showing the cmd window. The EM-Agent will wait max. 10 minutes until he starts the next action. If you don't use ActionOnErrorResumeNext, the sequence will stop with an error. .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [string]$ProcessName=$null, [Parameter(Mandatory=$false,Position=1)] [ValidateSet("Start", "Kill")] [string]$ProcessActionType="Start", [Parameter(Mandatory=$false,Position=2)] [string]$Arguments=$null, [Parameter(Mandatory=$false,Position=3)] [ValidateSet("Visible", "Invisible")] $StartProcessVisible="Visible", [Parameter(Mandatory=$false,Position=4)] [ValidateSet("System", "User")] $Context="System", [Parameter(Mandatory=$false,Position=5)] [bool]$WaitForEnd=$true, [Parameter(Mandatory=$false,Position=6)] [int]$MaxRunTime= 0, [Parameter(Mandatory=$false,Position=7)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=8)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=9)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=10)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=11)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=12)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a process action." -Component New-EMProcessAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the processname and startup type to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""ProcessActionType"" ($ProcessActionType)" -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose Add-KabompoLogLine -Message "Add parameter ""ProcessActionType"" ($ProcessActionType)" -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$ProcessActionType Add-KabompoLogLine -Message "Add parameter ""ProcessName"" ($ProcessName)" -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$ProcessName Add-KabompoLogLine -Message "Add parameter ""Arguments"" ($Arguments)" -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$Arguments Add-KabompoLogLine -Message "Add parameter ""StartProcessVisible"" ($StartProcessVisible)" -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose if($StartProcessVisible -eq "Visible") { $Parameters += ,"User" } else { $Parameters += ,"Admin" } Add-KabompoLogLine -Message "Add parameter ""Context"" ($Context)" -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$Context Add-KabompoLogLine -Message "Add parameter ""WaitForEnd"" ($WaitForEnd)" -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$WaitForEnd Add-KabompoLogLine -Message "Add parameter ""MaxRunTime"" ($MaxRunTime)" -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$MaxRunTime # Format german and english name $EnDefaultDisplayName = "{0} process ""{1}""" -f $ProcessActionType, $ProcessName if($ProcessActionType -eq "Start") { $DeDefaultDisplayName = "Starte Prozess ""{0}""" -f $ProcessName } if($ProcessActionType -eq "Stop") { $DeDefaultDisplayName = "Stoppe Prozess ""{0}""" -f $ProcessName } if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Process" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""ProcessActionType,ProcessName,Arguments,StartProcessVisible,Context,WaitForEnd,MaxRunTime"" to the PS-Object." -Component New-EMProcessAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the file property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "ProcessActionType" -Value $ProcessActionType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "ProcessName" -Value $ProcessName Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Arguments" -Value $Arguments Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "StartProcessVisible" -Value $StartProcessVisible Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Context" -Value $Context Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "WaitForEnd" -Value $WaitForEnd Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "MaxRunTime" -Value $MaxRunTime # Add Process-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("ProcessActionType") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("ProcessName") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Arguments") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("StartProcessVisible") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Context") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("WaitForEnd") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("MaxRunTime") Add-KabompoLogLine -Message "Finished creating process action for process $ProcessName." -Component New-EMProcessAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMProcessAction -Type 3 -Verbose:$DoVerbose $EMAction=$null throw $_.Exception } } function New-EMServiceAction { <# .SYNOPSIS Creates a local service-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local service-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMServiceAction -ServiceName spooler -ProcessActionType Stop Will stop the spooler service. .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] [string]$ServiceName=$null, [Parameter(Mandatory=$true,Position=2)] [ValidateSet("Start", "Stop")] [string]$ServiceActionType, [Parameter(Mandatory=$false,Position=3)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=4)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=5)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=6)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=7)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=8)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a service action." -Component New-EMProcessAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the servicename and startup type to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""ServiceName"" ($ServiceName)" -Component New-EMServiceAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$ServiceName Add-KabompoLogLine -Message "Add parameter ""ActionType"" ($ServiceActionType)" -Component New-EMServiceAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$ServiceActionType # Format german and english name $EnDefaultDisplayName = "{0} windows service ""{1}""" -f $ServiceActionType, $ServiceName if($ServiceActionType -eq "Start") { $DeDefaultDisplayName = "{0}e Windows Dienst ""{1}""" -f $ServiceActionType, $ServiceName } if($ServiceActionType -eq "Stop") { $DeDefaultDisplayName = "{0}pe Windows Dienst ""{1}""" -f $ServiceActionType, $ServiceName } if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMServiceAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Service" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMServiceAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""ServiceName,ServiceActionType"" to the PS-Object." -Component New-EMServiceAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the file property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "ServiceName" -Value $ServiceName Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "ServiceActionType" -Value $ServiceActionType # Add Service-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("ServiceName") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("ServiceActionType") Add-KabompoLogLine -Message "Finished creating service action for service $ServiceName." -Component New-EMServiceAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMServiceAction -Type 3 -Verbose:$DoVerbose $EMAction = $null throw $_.Exception } } function New-EMRestartAction { <# .SYNOPSIS Creates a local reboot/shutdown-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local reboot/shutdown-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMRestartAction -RestartActionType Reboot Will reboot the system. Open applications will not beeing forced to be closed, the user can move the time and there is no autorestart. .EXAMPLE New-EMRestartAction -RestartActionType Shutdown -KillApplications Force -UserCanMoveTime Force Will shutdown the system, all applications will be forced, the user can not move the time. .EXAMPLE New-EMRestartAction -RestartActionType Reboot -AutoRestart 10 Will reboot the system. Open applications will not beeing forced to be closed, the user can move the time and teh reboot will be done automatically after 10 minutes. .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateSet("Reboot", "Shutdown")] [string]$RestartActionType=$null, [Parameter(Mandatory=$false,Position=1)] [ValidateSet("Force", "Wait")] [string]$KillApplications="Wait", [Parameter(Mandatory=$false,Position=2)] [ValidateSet("Force", "Moveable")] [string]$UserCanMoveTime="Movable", [Parameter(Mandatory=$false,Position=3)] [int]$AutoRestart=0, [Parameter(Mandatory=$false,Position=4)] [string]$DeMessage=$null, [Parameter(Mandatory=$false,Position=5)] [string]$EnMessage=$null, [Parameter(Mandatory=$false,Position=6)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=7)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=8)] [int]$SortKey=0, [Parameter(Mandatory=$false,Position=9)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=10)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=11)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a restart action." -Component New-EMRestartAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the servicename and startup type to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""RestartActionType"" ($RestartActionType)" -Component New-EMRestartAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$RestartActionType Add-KabompoLogLine -Message "Add parameter ""KillApplications"" ($KillApplications)" -Component New-EMRestartAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$KillApplications Add-KabompoLogLine -Message "Add parameter ""UserCanMoveTime"" ($UserCanMoveTime)" -Component New-EMRestartAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$UserCanMoveTime Add-KabompoLogLine -Message "Add parameter ""AutoRestart"" ($AutoRestart)" -Component New-EMRestartAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$AutoRestart if([String]::IsNullOrEmpty($DeMessage)) { $DeMessage = "Der Computer muss aufgrund von Wartungsarbeiten neu gestartet werden" } Add-KabompoLogLine -Message "Add parameter ""DeMessage"" ($DeMessage)" -Component New-EMRestartAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$DeMessage if([String]::IsNullOrEmpty($EnMessage)) { $EnMessage = "The computer must be restarted due to maintenance tasks" } Add-KabompoLogLine -Message "Add parameter ""EnMessage"" ($EnMessage)" -Component New-EMRestartAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$EnMessage # Format german and english name $EnDefaultDisplayName = "{0} computer" -f $RestartActionType if($RestartActionType -eq "Reboot") { $DeDefaultDisplayName = "Starte Computer neu"} else { $DeDefaultDisplayName = "Fahre Computer herunter"} if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMRestartAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Restart" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMRestartAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""RestartActionType,KillApplications,UserCanMoveTime,AutoRestart,DeMessage,EnMessage"" to the PS-Object." -Component New-EMRestartAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the file property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "RestartActionType" -Value $RestartActionType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "KillApplications" -Value $KillApplications Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "UserCanMoveTime" -Value $UserCanMoveTime Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "AutoRestart" -Value $AutoRestart Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "DeMessage" -Value $DeMessage Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "EnMessage" -Value $EnMessage # Add Service-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("RestartActionType") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("KillApplications") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("UserCanMoveTime") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("AutoRestart") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("DeMessage") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("EnMessage") Add-KabompoLogLine -Message "Finished creating restart ($RestartActionType) action." -Component New-EMRestartAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMRestartAction -Type 3 -Verbose:$DoVerbose $EMAction = $null throw $_.Exception } } function New-EMFileAction { <# .SYNOPSIS Creates a local file-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local file-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMFileAction -FileActionType Create -FilePath c:\empssdk.txt Will create the empty file "c:\empssdk.txt". .EXAMPLE New-EMFileAction -FileActionType Create -FilePath c:\empssdk.txt -Text "This is an example file". Will create the empty file "c:\empssdk.txt" with the text "This is an example file". .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateSet("Create", "Remove")] [string]$FileActionType=$null, [Parameter(Mandatory=$true,Position=1)] $FilePath=$null, [Parameter(Mandatory=$false,Position=2)] $Text=$null, [Parameter(Mandatory=$false,Position=3)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=4)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=5)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=6)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=7)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=8)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a file action." -Component New-EMFileAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the file parameters to a parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""FileActionType"" ($FileActionType)" -Component New-EMFileAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$FileActionType Add-KabompoLogLine -Message "Add parameter ""FilePath"" ($FilePath)" -Component New-EMFileAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$FilePath if($Text -eq $null) { $Text = " " } Add-KabompoLogLine -Message "Add parameter ""Text"" ($Text)" -Component New-EMFileAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$Text # Format german and english name $EnDefaultDisplayName = "{0} file ""{1}""" -f $FileActionType, $FilePath if($FileActionType -eq "Create") { $DeDefaultDisplayName = "Erstelle Datei ""{0}""" -f $FilePath } else { $DeDefaultDisplayName = "Lösche Datei ""{0}""" -f $FilePath } if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMFileAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "File" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMFileAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""FileActionType"", ""FilePath"" and ""Text"" to the PS-Object." -Component New-EMFileAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the file property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "FileActionType" -Value $FileActionType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "FilePath" -Value $FilePath Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Text" -Value $Text # Add Service-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("FileActionType") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("FilePath") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Text") Add-KabompoLogLine -Message "Finished creating file action." -Component New-EMFileAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMFileAction -Type 3 -Verbose:$DoVerbose $EMAction = $null throw $_.Exception } } function New-EMInfoAction { <# .SYNOPSIS Creates a local info-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local info-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMInfoAction -HeadlineGerman "empssdk_headline_de" -HeadlineEnglish "empssdk_headline_en" -TextGerman "empssdk_text_de" -TextEnglish "empssdk_text_en" -Width 599 -Height 399 -AutoClose 999 -Wait Continue -Close CloseDenied -ActionOnErrorResumeNext $true -ConditionOnErrorResumeNext $true -SortKey 0 -DeDisplayName "Pester_show_info_de" -EnDisplayName "Pester_show_info_en" Will create an info message which shows custom information to the user. The EM agent will go on with actions and its denied to the user to close the window .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$false,Position=0)] [string]$HeadlineGerman=$null, [Parameter(Mandatory=$false,Position=1)] [string]$HeadlineEnglish=$null, [Parameter(Mandatory=$false,Position=2)] [string]$TextGerman=$null, [Parameter(Mandatory=$false,Position=3)] [string]$TextEnglish=$null, [Parameter(Mandatory=$false,Position=4)] [int]$Width=600, [Parameter(Mandatory=$false,Position=5)] [int]$Height=400, [Parameter(Mandatory=$false,Position=6)] [int]$AutoClose=0, # 0=Never; 999=After task is finished; 1-180 for minute intervall [Parameter(Mandatory=$false,Position=7)] [ValidateSet("Wait", "Continue")] $Wait="Wait", [Parameter(Mandatory=$false,Position=8)] [ValidateSet("Close", "CloseDenied")] $Close="Close", [Parameter(Mandatory=$false,Position=9)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=10)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=11)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=12)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=13)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=14)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating an info action." -Component New-EMInfoAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the file parameters to a parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""HeadlineGerman"" ($HeadlineGerman)" -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$HeadlineGerman Add-KabompoLogLine -Message "Add parameter ""HeadlineEnglish"" ($HeadlineEnglish)" -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$HeadlineEnglish Add-KabompoLogLine -Message "Add parameter ""TextGerman"" ($TextGerman)" -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$TextGerman Add-KabompoLogLine -Message "Add parameter ""TextEnglish"" ($TextEnglish)" -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$TextEnglish Add-KabompoLogLine -Message "Add parameter ""Width"" ($Width)" -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$Width Add-KabompoLogLine -Message "Add parameter ""Height"" ($Height)" -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$Height Add-KabompoLogLine -Message "Add parameter ""AutoClose"" ($AutoClose)" -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$AutoClose Add-KabompoLogLine -Message "Add parameter ""Wait"" ($Wait)" -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$Wait Add-KabompoLogLine -Message "Add parameter ""Close"" ($Close)" -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$Close # Check if a headline is given if([String]::IsNullOrEmpty($HeadlineGerman) -and [String]::IsNullOrEmpty($HeadlineEnglish)) { throw "At minimum an english or german headline must be given." } # Override headlines with null value if([string]::IsNullOrEmpty($HeadlineGerman)) { $HeadlineGerman = $HeadlineEnglish } if([string]::IsNullOrEmpty($HeadlineEnglish)) { $HeadlineEnglish = $HeadlineGerman } # Format german and english name $EnDefaultDisplayName = "Show information ""{0}""" -f $HeadlineEnglish $DeDefaultDisplayName = "Zeige information ""{0}""" -f $HeadlineGerman if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Info" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""Headline"", ""AutoClose"", ""Wait"" and ""Close"" to the PS-Object." -Component New-EMInfoAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the file property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "HeadlineGerman" -Value $HeadlineGerman Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "HeadlineEnglish" -Value $HeadlineEnglish Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "TextGerman" -Value $TextGerman Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "TextEnglish" -Value $TextEnglish Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Width" -Value $Width Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Height" -Value $Height Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "AutoClose" -Value $AutoClose Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Wait" -Value $Wait Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Close" -Value $Close # Add Service-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("HeadlineGerman") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("HeadlineEnglish") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("TextGerman") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("TextEnglish") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Width") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Height") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("AutoClose") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Wait") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Close") Add-KabompoLogLine -Message "Finished creating file action." -Component New-EMInfoAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMInfoAction -Type 3 -Verbose:$DoVerbose $EMAction = $null throw $_.Exception } } function New-EMFolderAction { <# .SYNOPSIS Creates a local folder-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local folder-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMFolderAction -FolderActionType Create -FolderPath c:\empssdk Will create the folder "c:\empssdk". .EXAMPLE New-EMFolderAction -FolderActionType Remove -FolderPath c:\empssdk Will remove the folder "c:\empssdk". .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateSet("Create", "Remove")] [string]$FolderActionType=$null, [Parameter(Mandatory=$true,Position=1)] $FolderPath=$null, [Parameter(Mandatory=$false,Position=3)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=4)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=5)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=6)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=7)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=8)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a folder action." -Component New-EMFolderAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the folder parameters to a parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""FolderActionType"" ($FolderActionType)" -Component New-EMFolderAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$FolderActionType Add-KabompoLogLine -Message "Add parameter ""FolderPath"" ($FolderPath)" -Component New-EMFolderAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$FolderPath # Format german and english name $EnDefaultDisplayName = "{0} folder ""{1}""" -f $FolderActionType, $FolderPath if($FolderActionType -eq "Create") { $DeDefaultDisplayName = "Erstelle Verzeichnis ""{0}""" -f $FolderPath } else { $DeDefaultDisplayName = "Lösche Verzeichnis ""{0}""" -f $FolderPath } if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMFolderAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Folder" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMFolderAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""FolderActionType"" and ""FolderPath"" to the PS-Object." -Component New-EMFolderAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the folder property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "FolderActionType" -Value $FolderActionType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "FolderPath" -Value $FolderPath # Add Service-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("FolderActionType") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("FolderPath") Add-KabompoLogLine -Message "Finished creating folder action." -Component New-EMFolderAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMFolderAction -Type 3 -Verbose:$DoVerbose $EMAction = $null throw $_.Exception } } function New-EMMonitoringAction { <# .SYNOPSIS Creates a local monitoring-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local monitoring-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMMonitoringAction -Processes "winword.exe" Check if the process "winword.exe" is running and shows a warning to the user. .EXAMPLE New-EMMonitoringAction -Processes "winword.exe" -AutoClose 10 Check if the process "winword.exe" is running and shows a warning to the user. The action will kill the winword process after 10 minutes automatically. .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$false,Position=0)] [int]$AutoClose=0, [Parameter(Mandatory=$true,Position=1)] $Processes=$null, [Parameter(Mandatory=$false,Position=2)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=3)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=4)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=5)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=6)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=7)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a monitoring action." -Component New-EMMonitoringAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the servicename and startup type to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""AutoClose"" ($AutoClose)" -Component New-EMMonitoringAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$AutoClose Add-KabompoLogLine -Message "Add parameter ""Processes"" ($Processes)" -Component New-EMMonitoringAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose foreach($process in $Processes) { $Parameters += ,$process } # Format german and english name $EnDefaultDisplayName = "Monitor ""{0}"" processes" -f $($Parameters.Count) $DeDefaultDisplayName = "Überwache ""{0}"" Prozesses" -f $($Parameters.Count) if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMMonitoringAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Monitoring" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMMonitoringAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""AutoClose"" and ""Processes"" to the PS-Object." -Component New-EMMonitoringAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the folder property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "AutoClose" -Value $AutoClose Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Processes" -Value $Processes # Add Service-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("AutoClose") Add-KabompoLogLine -Message "Finished creating monitoring action." -Component New-EMMonitoringAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMMonitoringAction -Type 3 -Verbose:$DoVerbose $EMAction = $null throw $_.Exception } } function New-EMRegistryAction { <# .SYNOPSIS Creates a local registry-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local registry-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMRegistryAction -RegistryActionType Create -RegistryKey Check if the process "winword.exe" is running and shows a warning to the user. .EXAMPLE New-EMMonitoringAction -Processes "winword.exe" -AutoClose 10 Check if the process "winword.exe" is running and shows a warning to the user. The action will kill the winword process after 10 minutes automatically. .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateSet("Create", "Remove")] [string]$RegistryActionType=$null, [Parameter(Mandatory=$false,Position=1)] [string]$RegistryKey=$null, [Parameter(Mandatory=$false,Position=2)] [string]$ValueName=$null, [Parameter(Mandatory=$false,Position=3)] [ValidateSet("String", "Binary", "DWord", "MultiString", "ExpandString")] [string]$ValueType=$null, [Parameter(Mandatory=$false,Position=4)] [string]$Value=$null, [Parameter(Mandatory=$false,Position=5)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=6)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=7)] [int]$SortKey=0, [Parameter(Mandatory=$false,Position=8)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=9)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=10)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a restart action." -Component New-EMRegistryAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the servicename and startup type to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""RegistryActionType"" ($RegistryActionType)" -Component New-EMRegistryAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$RegistryActionType Add-KabompoLogLine -Message "Add parameter ""RegistryKey"" ($RegistryKey)" -Component New-EMRegistryAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$RegistryKey Add-KabompoLogLine -Message "Add parameter ""ValueName"" ($ValueName)" -Component New-EMRegistryAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$ValueName Add-KabompoLogLine -Message "Add parameter ""ValueType"" ($ValueType)" -Component New-EMRegistryAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$ValueType Add-KabompoLogLine -Message "Add parameter ""Value"" ($Value)" -Component New-EMRegistryAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$Value # Format german and english name $EnDefaultDisplayName = "{0} Registry key/value" -f $RegistryActionType if($RegistryActionType -eq "Create") { $DeDefaultDisplayName = "Erstelle Registry Key/Value"} else { $DeDefaultDisplayName = "Lösche registry Key/Value"} if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMRegistryAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Registry" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMRegistryAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""RegistryActionType,RegistryKey,ValueName,ValueType,Value"" to the PS-Object." -Component New-EMRegistryAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the reigstry property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "RegistryActionType" -Value $RegistryActionType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "RegistryKey" -Value $RegistryKey Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "ValueName" -Value $ValueName Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "ValueType" -Value $ValueType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Value" -Value $Value # Add Service-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("RegistryActionType") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("RegistryKey") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("ValueName") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("ValueType") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Value") Add-KabompoLogLine -Message "Finished creating registry ($RegistryActionType) action." -Component New-EMRegistryAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMRegistryAction -Type 3 -Verbose:$DoVerbose $EMAction = $null throw $_.Exception } } function New-EMAccountAction { <# .SYNOPSIS Creates a local account-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local account-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMAccountAction -Account empssdk -AccountType Account -LocalOrGlobalAccount Local -LocalTargetObject "Administrators" -TargetObjectType Group -AccountActionType Add Add's the local account empssdk to the local Administrators group. .EXAMPLE New-EMAccountAction -Account empssdk -AccountType Account -LocalOrGlobalAccount Global -AdTargetObject "GLB_EM_Administrators" -TargetObjectType Group -AdAccessObject "Domain\Administrator" -AdAccessObjectType "Account" -AdAccessObjectPwdEncrypted "1§fsdE567%$"§$42FW$§%SFcvd" -AccountActionType Remove Removes the Active Directory Account "empssdk" from the Active Directory group "GLB_EM_Administrators" and uses the account "Domain\Administrators" to access the Active Directory. .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [string]$Account=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateSet("Group", "Account")] [string]$AccountType=$null, [Parameter(Mandatory=$true,Position=2)] [ValidateSet("Local", "Global")] [string]$LocalOrGlobalAccount=$null, [Parameter(Mandatory=$false,Position=3)] [string]$LocalTargetObject=$null, [Parameter(Mandatory=$false,Position=4)] [string]$AdTargetObject=$null, [Parameter(Mandatory=$false,Position=5)] [ValidateSet("Group", "Account")] [string]$TargetObjectType=$null, [Parameter(Mandatory=$false,Position=6)] [string]$AdAccessObject=$null, [Parameter(Mandatory=$false,Position=7)] [ValidateSet("Group", "Account")] [string]$AdAccessObjectType="Account", [Parameter(Mandatory=$false,Position=8)] [string]$AdAccessObjectPwdEncrypted=$null, [Parameter(Mandatory=$true,Position=9)] [ValidateSet("Add", "Remove")] [string]$AccountActionType=$null, [Parameter(Mandatory=$false,Position=10)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=11)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=12)] [int]$SortKey=0, [Parameter(Mandatory=$false,Position=13)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=14)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=15)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating an account action." -Component New-EMAccountAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the servicename and startup type to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""Account"" ($Account)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$Account Add-KabompoLogLine -Message "Add parameter ""AccountType"" ($AccountType)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$AccountType Add-KabompoLogLine -Message "Add parameter ""LocalOrGlobalAccount"" ($LocalOrGlobalAccount)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$LocalOrGlobalAccount if([String]::IsNullOrEmpty($LocalTargetObject)) { $LocalTargetObject = "x" } Add-KabompoLogLine -Message "Add parameter ""LocalTargetObject"" ($LocalTargetObject)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$LocalTargetObject if([String]::IsNullOrEmpty($AdTargetObject)) { $AdTargetObject = "x" } Add-KabompoLogLine -Message "Add parameter ""AdTargetObject"" ($AdTargetObject)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$AdTargetObject Add-KabompoLogLine -Message "Add parameter ""TargetObjectType"" ($TargetObjectType)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$TargetObjectType if([String]::IsNullOrEmpty($AdAccessObject)) { $AdAccessObject = "x" } Add-KabompoLogLine -Message "Add parameter ""AdAccessObject"" ($AdAccessObject)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$AdAccessObject Add-KabompoLogLine -Message "Add parameter ""AdAccessObjectType"" ($AdAccessObjectType)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$AdAccessObjectType if([String]::IsNullOrEmpty($AdAccessAcountPwdEncrypted)) { $AdAccessAcountPwdEncrypted = "x" } Add-KabompoLogLine -Message "Add parameter ""AdAccessAcountPwdEncrypted"" ($AdAccessAcountPwdEncrypted)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$AdAccessAcountPwdEncrypted Add-KabompoLogLine -Message "Add parameter ""AccountActionType"" ($AccountActionType)" -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$AccountActionType # Format german and english name if($RegistryActionType -eq "Remove") { if($LocalOrGlobalAccount -eq "Local") { $EnDefaultDisplayName = "Remove Account {0} from group {1}" -f $Account, $LocalTargetObject } else { $EnDefaultDisplayName = "Remove Account {0} from group {1}" -f $Account, $AdTargetObject } } else { if($LocalOrGlobalAccount -eq "Local") { $EnDefaultDisplayName = "Add Account {0} to group {1}" -f $Account, $LocalTargetObject } else { $EnDefaultDisplayName = "Add Account {0} to group {1}" -f $Account, $AdTargetObject } } if($RegistryActionType -eq "Remove") { if($LocalOrGlobalAccount -eq "Local") { $DeDefaultDisplayName = "Enferne den Account {0} aus der Gruppe {1}" -f $Account, $LocalTargetObject } else { $DeDefaultDisplayName = "Enferne den Account {0} aus der Gruppe {1}" -f $Account, $AdTargetObject } } else { if($LocalOrGlobalAccount -eq "Local") { $DeDefaultDisplayName = "Füge den Account {0} der Gruppe {1} hinzu" -f $Account, $LocalTargetObject } else { $DeDefaultDisplayName = "Füge den Account {0} der Gruppe {1} hinzu" -f $Account, $AdTargetObject } } if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Account" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""Account,AccountType,LocalTargetObject,AdTargetObject,AccountActionType"" to the PS-Object." -Component New-EMAccountAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the account property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "Account" -Value $Account Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "AccountType" -Value $AccountType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "LocalOrGlobalAccount" -Value $LocalOrGlobalAccount Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "LocalTargetObject" -Value $LocalTargetObject Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "AdTargetObject" -Value $AdTargetObject Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "TargetObjectType" -Value $TargetObjectType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "AdAccessObject" -Value $AdAccessObject Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "AdAccessObjectType" -Value $AdAccessObjectType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "AdAccessAcountPwdEncrypted" -Value $AdAccessAcountPwdEncrypted Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "AccountActionType" -Value $AccountActionType # Add Service-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Account") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("AccountType") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("LocalTargetObject") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("AdTargetObject") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("AccountActionType") Add-KabompoLogLine -Message "Finished creating account ($AccountActionType) action." -Component New-EMAccountAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMAccountAction -Type 3 -Verbose:$DoVerbose $EMAction = $null throw $_.Exception } } function New-EMSccmApplicationAction { <# .SYNOPSIS Creates a local SCCM-Application-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local SCCM-Application-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] $SccmApplicationId=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateSet("Install", "Uninstall")] $SccmApplicationActionType=$null, [Parameter(Mandatory=$false,Position=2)] $SccmApplicationParam=$null, [Parameter(Mandatory=$false,Position=3)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=4)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=5)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=6)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=7)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=8)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a sccm application action." -Component New-EMSccmApplicationAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the pproperties to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""SccmApplicationId"" ($SccmApplicationId)" -Component New-EMSccmApplicationAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$SccmApplicationId Add-KabompoLogLine -Message "Add parameter ""SccmApplicationActionType"" ($SccmApplicationActionType)" -Component New-EMSccmApplicationAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$SccmApplicationActionType if(!([String]::IsNullOrEmpty($SccmApplicationParam))) { Add-KabompoLogLine -Message "Add parameter ""SccmApplicationParam"" ($SccmApplicationParam)" -Component New-EMSccmApplicationAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$SccmApplicationParam } else { $Parameters += " " } # Format german and english name $EnDefaultDisplayName = "{0} SCCM Application" -f $SccmApplicationActionType if($SccmApplicationActionType -eq "Install") { $DeDefaultDisplayName = "Installiere SCCM-Application" } if($SccmApplicationActionType -eq "Uninstall") { $DeDefaultDisplayName = "Deinstalliere SCCM-Application" } if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMSccmApplicationAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Application" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMSccmApplicationAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""SCCMApplicationId,SCCMApplicationActionType,SCCMApplicationParam"" to the PS-Object." -Component New-EMSccmApplicationAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the application property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "SccmApplicationId" -Value $SccmApplicationId Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "SccmApplicationActionType" -Value $SccmApplicationActionType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "SccmApplicationParam" -Value $SccmApplicationParam # Add Application-Properties as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SccmApplicationName") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SccmApplicationId") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SccmApplicationActionType") Add-KabompoLogLine -Message "Finished creating application action for SCCM-application $SccmApplicationName." -Component New-EMSccmApplicationAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMSccmApplicationAction -Type 3 -Verbose:$DoVerbose $EMAction=$null throw $_.Exception } } function New-EMSccmPackageAction { <# .SYNOPSIS Creates a local SCCM-Package-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local SCCM-Package-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] $SccmPackageId=$null, [Parameter(Mandatory=$false,Position=1)] $SccmPackageProgram=$null, [Parameter(Mandatory=$false,Position=2)] $SccmPackageParam=$null, [Parameter(Mandatory=$true,Position=3)] [ValidateSet("Install", "Uninstall")] $SccmPackageActionType=$null, [Parameter(Mandatory=$false,Position=4)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=5)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=6)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=7)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=8)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=9)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a sccm package action." -Component New-EMSccmPackageAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the pproperties to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""SccmApplicationId"" ($SccmPackageId)" -Component New-EMSccmPackageAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$SccmPackageId Add-KabompoLogLine -Message "Add parameter ""SccmPackageProgram"" ($SccmPackageProgram)" -Component New-EMSccmPackageAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$SccmPackageProgram Add-KabompoLogLine -Message "Add parameter ""SccmApplicationParam"" ($SccmPackageParam)" -Component New-EMSccmPackageAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$SccmPackageParam Add-KabompoLogLine -Message "Add parameter ""SccmApplicationActionType"" ($SccmPackageActionType)" -Component New-EMSccmPackageAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$SccmPackageActionType # Format german and english name $EnDefaultDisplayName = "{0} SCCM Package" -f $SccmPackageActionType if($SccmPackageActionType -eq "Install") { $DeDefaultDisplayName = "Installiere SCCM-Paket" } if($SccmPackageActionType -eq "Uninstall") { $DeDefaultDisplayName = "Deinstalliere SCCM-Package" } if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMSccmPackageAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Software" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMSccmPackageAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""SCCMPackageId,SCCMPackageActionType,SCCMPackageParam"" to the PS-Object." -Component New-EMSccmPackageAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the package property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "SccmPackageId" -Value $SccmPackageId Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "SccmPackageProgram" -Value $SccmPackageProgram Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "SccmPackageParam" -Value $SccmPackageParam Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "SccmPackageActionType" -Value $SccmPackageActionType # Add Package-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SccmPackageId") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SccmPackageProgram") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SccmPackageParam") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SccmPackageActionType") Add-KabompoLogLine -Message "Finished creating package action for SCCM-Program $SccmPackageId." -Component New-EMSccmPackageAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMSccmPackageAction -Type 3 -Verbose:$DoVerbose $EMAction=$null throw $_.Exception } } function New-EMSccmDownloadAction { <# .SYNOPSIS Creates a local SCCM-Package-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local SCCM-Package-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] $SccmPackageId=$null, [Parameter(Mandatory=$false,Position=1)] $DownloadFolder=$null, [Parameter(Mandatory=$false,Position=2)] $SccmPackageName=$null, [Parameter(Mandatory=$false,Position=4)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=5)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=6)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=7)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=8)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=9)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a package download action." -Component New-EMSccmDownloadAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the pproperties to parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""SccmPackageId"" ($SccmPackageId)" -Component New-EMSccmDownloadAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$SccmPackageId Add-KabompoLogLine -Message "Add parameter ""DownloadFolder"" ($DownloadFolder)" -Component New-EMSccmDownloadAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$DownloadFolder Add-KabompoLogLine -Message "Add parameter ""SccmPackageName"" ($SccmPackageName)" -Component New-EMSccmDownloadAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$SccmPackageName # Format german and english name $EnDefaultDisplayName = "Download SCCM Package ""{0}"" to folder ""{1}""" -f $SccmPackageName, $DownloadFolder $DeDefaultDisplayName = "Speichere SCCM Paket ""{0}"" in Verzeichnis ""{1}""" -f $SccmPackageName, $DownloadFolder if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMSccmDownloadAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "Download" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMSccmDownloadAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""SCCMPackageId,DownloadFolder,SCCMPackageName"" to the PS-Object." -Component New-EMSccmDownloadAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the package property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "SCCMPackageId" -Value $SccmPackageId Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "DownloadFolder" -Value $DownloadFolder Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "SCCMPackageName" -Value $SccmPackageName # Add Package-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SccmPackageId") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("DownloadFolder") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SccmPackageName") Add-KabompoLogLine -Message "Finished creating package download action for SCCM-Program $SccmPackageId." -Component New-EMSccmDownloadAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMSccmDownloadAction -Type 3 -Verbose:$DoVerbose $EMAction=$null throw $_.Exception } } function New-EMVariableAction { <# .SYNOPSIS Creates a local variable-action object which you can edit and add to a sequence. .DESCRIPTION Creates a local variable-action object which you can edit and add to a sequence. Use the AddAction() Method which is available in an EMSequence object to add the action to a sequence. .EXAMPLE New-EMVariableAction -VariableActionType Create -VariableName empssdk_var_name -VariableValue empssdk_var_name Will create the variable "empssdk_var_name". .EXAMPLE New-EMVariableAction -VariableActionType Remove -VariableName empssdk_var_name Will remove the variable "empssdk_var_name". .EXAMPLE New-EMVariableAction -VariableActionType Create -VariableName empssdk_var_name -VariableValueType LastExitCode Will create the variable "empssdk_var_name" with the exit code of the last executable as value. .EXAMPLE New-EMVariableAction -VariableActionType Create -VariableName empssdk_var_name -VariableValue empssdk_var_name -VariableScope Machine Will create the variable "empssdk_var_name" and set this as machine wide variable. .NOTES Use "-EnDisplayName" or "-DeDisplayName" to customize the title of the action which is shown in the Admin-UI and the EM-Agent. .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateSet("Create", "Remove")] [string]$VariableActionType=$null, [Parameter(Mandatory=$true,Position=1)] $VariableName=$null, [Parameter(Mandatory=$false,Position=2)] [ValidateSet("OwnValue", "LastExitCode")] $VariableValueType="OwnValue", [Parameter(Mandatory=$false,Position=3)] [ValidateSet("Process", "Machine")] $VariableScope="Process", [Parameter(Mandatory=$false,Position=4)] $VariableValue=$null, [Parameter(Mandatory=$false,Position=3)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=4)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$false,Position=5)] [int]$SortKey= 0, [Parameter(Mandatory=$false,Position=6)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$false,Position=7)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$false,Position=8)] $EMApiAction=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a variable action." -Component New-EMVariableAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Add the folder parameters to a parameter list $Parameters = @() Add-KabompoLogLine -Message "Add parameter ""VariableName"" ($VariableName)" -Component New-EMVariableAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$VariableName Add-KabompoLogLine -Message "Add parameter ""VariableActionType"" ($VariableActionType)" -Component New-EMVariableAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$VariableActionType Add-KabompoLogLine -Message "Add parameter ""VariableScope"" ($VariableScope)" -Component New-EMVariableAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$VariableScope Add-KabompoLogLine -Message "Add parameter ""VariableValueType"" ($VariableValueType)" -Component New-EMVariableAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$VariableValueType Add-KabompoLogLine -Message "Add parameter ""VariableValue"" ($VariableValue)" -Component New-EMVariableAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $Parameters += ,$VariableValue # Format german and english name $EnDefaultDisplayName = "{0} variable ""{1}""" -f $VariableActionType, $VariableName if($VariableActionType -eq "Create") { $DeDefaultDisplayName = "Erstelle Variable ""{0}""" -f $VariableName } else { $DeDefaultDisplayName = "Lösche Variable ""{0}""" -f $VariableName } if([String]::IsNullOrEmpty($EnDisplayName)) { $EnDisplayName = $EnDefaultDisplayName } if([String]::IsNullOrEmpty($DeDisplayName)) { $DeDisplayName = $DeDefaultDisplayName } # Create EM-Api-Object if it's not given if($EMApiAction -eq $null) { Add-KabompoLogLine -Message "Create API object." -Component New-EMVariableAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMApiAction = New-EMApiAction -ActionType "EnvironmentVar" -Parameter $Parameters -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -DeDefaultDisplayName $DeDefaultDisplayName -EnDefaultDisplayName $EnDefaultDisplayName -ActionOnErrorResumeNext $ActionOnErrorResumeNext -ConditionOnErrorResumeNext $ConditionOnErrorResumeNext -SortKey $SortKey $global:logIndention-- } # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object." -Component New-EMVariableAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMAction = New-EMActionObject -Id $EMApiAction.ID -ActionType $EMApiAction.Type -DeActionName $DeDisplayName -EnActionName $EnDisplayName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Add properties ""VariableActionType"", ""VariableName"", ""VariableValueType"", ""VariableScope"" and ""VariableValue"" to the PS-Object." -Component New-EMVariableAction -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Add the folder property to the EM Object Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "VariableActionType" -Value $VariableActionType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "VariableName" -Value $VariableName Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "VariableValueType" -Value $VariableValueType Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "VariableScope" -Value $VariableScope Add-Member -InputObject $EMAction -MemberType NoteProperty -Name "VariableValue" -Value $VariableValue # Add Service-Properties" as referenced property type $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("VariableActionType") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("VariableName") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("VariableValueType") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("VariableScope") $EMAction.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("VariableValue") Add-KabompoLogLine -Message "Finished creating variable action." -Component New-EMVariableAction -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return newly created object return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMVariableAction -Type 3 -Verbose:$DoVerbose $EMAction = $null throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUWFcmkN4H4I4ags1ftNZ/UoJV # NEygggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw # ggEKAoIBAQDHZNuFnBatHdyRnMUJ2Y1P6k49MjD04t9S7ukWj8upP/B6wPRYzzQf # 6QVMPKzMhNTPfIXaIEzi/jhT0jjwnXC0O9hF2rwTpDRnVOnVJemaqd2XsSDVEBUY # yhH7QZ82Zwi1nnSgo69WL694L3f74ge6bRiRIJ/IoZawj+74NL/9B93kGKH89sew # VtqPoDwSklJmzc86Qlgw6X/WXenHw8n6k/htEIjkHpiE6iGkDZp1gAPBERIV/qi/ # HyIZpvsO3g9RvcWEDvRvq6ZsIPfAvtlOnVWPrvik96pEDugHKPtvyj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GCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FNrZsoXomipqLpxznBM5E06xxSH8MA0GCSqGSIb3DQEBAQUABIIBADe7RQpXbLSl # 4PTcdqSDUDI11moY0kHmWwa2WTu3haip2hNCepsUpIvwtbNodBGvPV7qhf8s+9Ge # 1JappwbA84Oiczsmnf73jAm8tvGB1Corfv7f+DhlHpan69UUQB+n/esFGlWd4H28 # mKjOBchJHg+9jYncnmAVv/6YorUZc11BCsYNW6tLzDMXHZyBAJajMCZhC5F+v2gX # 6Txaj457K4lPZvnkvH0sW02GJ40azfWHQIFFO81m5u4Gu9guS0SC5M/TyvOgiA67 # wSu3W2jI+a2iKBfbRZH7SOeBddHzbCQFlWXWNhRj/avw0JPAeoiwmoe+1tjG83wW # /E0yMPMWQNI= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMBase.Helper.ps1
Matrix42.EMPSSDK.EMBase.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: General functions # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- #EMConnection (PSObject) function New-EMConnectionObject { Param ( [string]$ServerName, [int]$SdkPort, [string]$Account, [string]$Language, [int]$DiffToUtc, $EMApiVersion, $EMApiConnection ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Create the object $o = New-Object -TypeName PSCustomObject Add-KabompoLogLine -Message "Start creating a local EMConnection-Object" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Server: $Server" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Port: $Port" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Account: $Account" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Language: $Language" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...DiffToUtc: $DiffToUtc" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...EMApiVersion: $EMApiVersion" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Server" -Value $ServerName Add-Member -InputObject $o -MemberType NoteProperty -Name "Port" -Value $SdkPort Add-Member -InputObject $o -MemberType NoteProperty -Name "Account" -Value $Account Add-Member -InputObject $o -MemberType NoteProperty -Name "Language" -Value $Language Add-Member -InputObject $o -MemberType NoteProperty -Name "DiffToUtc" -Value $DiffToUtc Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiVersion" -Value $EMApiVersion Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiConnection" -Value $EMApiConnection # Format the object Add-KabompoLogLine -Message "Add properties ""Server"", ""Port"", ""Account"", ""Language"", ""DiffToUtc""" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $VisibleProperties = @("Server", "Port", "Account", "Language", "DiffToUtc") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o # Specify the type name $o.PSObject.TypeNames.Clear() Add-KabompoLogLine -Message "Add type name ""EMConnection""" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $o.PSObject.TypeNames.Add("EMConnection") Add-KabompoLogLine -Message "Finished creating a local EMConnection-Object" -Component New-EMConnectionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMConnectionObject -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMFolder=$null $global:logIndention = $localIndent throw $_.Exception } } # Configure the visibility of Properties based on a string array function Format-EMObject { Param ( [string[]]$VisibleProperties, [object]$EMObject ) # define objects that should be visible in console output $VisiblePropertySet = New-Object System.Management.Automation.PSPropertySet("DefaultDisplayPropertySet", [string[]]$VisibleProperties) $VisibleMembers = [System.Management.Automation.PSMemberInfo[]]@($VisiblePropertySet) $EMObject | Add-Member MemberSet PSStandardMembers $VisibleMembers } function Get-ApiFilePath { Param ( [Parameter(Mandatory=$true,Position=0)] [string]$EMApiVersion=$null ) $apiPath = "{0}\api\{1}" -f $PSScriptRoot, $EMApiVersion if(!(Test-Path $apiPath)) { throw "The API version ""$EMApiVersion"" was not found on the local system." } return $apiPath } function Register-EMSdk { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateSet("6.4.0.16312","6.5.0.17117","7.0.0.16340","7.0.0.16353","7.0.1.17044","7.0.1.17065","7.0.3.17103")] [string]$EMApiVersion=$null ) # Specify the pathes, where the DLL file can be found $apiPath = Get-ApiFilePath -EMApiVersion $EMApiVersion $contractPath= "$apiPath\Matrix42.EM.Contract.dll" $sdkPath= "$apiPath\Matrix42.EM.Sdk.dll" try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start initializing EM-SDK" -Component Register-EMSdk -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Check if the contract file exist Add-KabompoLogLine -Message "Check if Contract exist in $contractPath" -Component Register-EMSdk -Type 1 -LogLevel 0 -Verbose:$DoVerbose if (!(Test-Path $contractPath)) { throw "The contract in path ""$($contractPath)"" does not exist!" } # Check if the SDK file exist Add-KabompoLogLine -Message "Check if SDK exist in $contractPath" -Component Register-EMSdk -Type 1 -LogLevel 0 -Verbose:$DoVerbose if (!(Test-Path $sdkPath)) { throw "The SDK in path ""$sdkPath"" does not exist!" } # Check the version of the contract file Add-KabompoLogLine -Message "Check if file version of contract match the expected version $EMApiVersion" -Component Register-EMSdk -Type 1 -LogLevel 0 -Verbose:$DoVerbose $contractFileVersion = (Get-Item $contractPath).VersionInfo.FileVersion if($contractFileVersion -ne $EMApiVersion) { throw "The version of the contract ({0}) does not match the expected version ({1})" -f $contractFileVersion, $EMApiVersion } # Check the version of the sdk file Add-KabompoLogLine -Message "Check if file version of sdk match the expected version $EMApiVersion" -Component Register-EMSdk -Type 1 -LogLevel 0 -Verbose:$DoVerbose $sdkFileVersion = (Get-Item $sdkPath).VersionInfo.FileVersion if($sdkFileVersion -ne $EMApiVersion) { throw "The version of the SDK ({0}) does not match the expected version ({1})" -f $sdkFileVersion, $EMApiVersion } # add dlls to powershell variables Add-KabompoLogLine -Message "Load contract" -Component Register-EMSdk -Type 1 -LogLevel 0 -Verbose:$DoVerbose $contractAsm=Add-Type -Path $contractPath Add-KabompoLogLine -Message "Load SDK" -Component Register-EMSdk -Type 1 -LogLevel 0 -Verbose:$DoVerbose $sdkAsm=Add-Type -Path $sdkPath # Create an object where the assembly reference should be stored $o = New-Object -TypeName PSCustomObject Add-KabompoLogLine -Message "Finished initializing the SDK" -Component Register-EMSdk -Type 1 -LogLevel 0 -Verbose:$DoVerbose } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component "Register-EMSdk" -Type 3 -LogLevel 0 -Verbose:$DoVerbose $global:logIndention = $localIndent throw $_.Exception } } function New-EMLocalizationObject { Param ( [string]$deDE = $null, [string]$enUS = $null ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) if([string]::IsNullOrEmpty($deDE) -and [string]::IsNullOrEmpty($enUS)) { throw "You have to provide at minimum on localized value." } if([string]::IsNullOrEmpty($enUS) -and ![string]::IsNullOrEmpty($deDE)) { $enUS = $deDE Add-KabompoLogLine -Message "No english value given. Set english value to german value." -Component New-EMLocalizationObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose } if([string]::IsNullOrEmpty($deDE) -and ![string]::IsNullOrEmpty($enUS)) { $deDE = $enUS Add-KabompoLogLine -Message "No german value given. Set german value to english value." -Component New-EMLocalizationObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose } # Put all languages into an array $localizationTable = @{ "de-DE" = $deDE; "en-US" = $enUS } # Create the object $o = New-Object -TypeName PSCustomObject # Add Value property with current locale Add-Member -InputObject $o -MemberType NoteProperty -Name "Value" -Value $localizationTable[(Get-Culture).IetfLanguageTag] # Add table to object Add-Member -InputObject $o -MemberType NoteProperty -Name "LocalizationTable" -Value $localizationTable #region Implement method "GetLocalName" to return the current name $fGetName = { Param ( [Parameter(Mandatory=$true, Position=0)] [ValidateSet('de-DE','en-US')] [string]$IetfLanguageTag = $null ) return $this.localizationTable[$IetfLanguageTag] } # Add function to object Add-Member -InputObject $o -MemberType ScriptMethod -Name "GetName" -Value $fGetName #endregion #region Implement method "UpdateName" to return the current name $fUpdateName = { Param ( [Parameter(Mandatory=$true, Position=0)] [ValidateSet('de-DE','en-US')] [string]$IetfLanguageTag = $null, [Parameter(Mandatory=$true, Position=1)] [string]$Value = $null ) if($IetfLanguageTag -eq "de-DE") { $this.localizationTable[$IetfLanguageTag] = $Value } elseif($IetfLanguageTag -eq "en-US") { $this.localizationTable[$IetfLanguageTag] = $Value } } # Add function to object Add-Member -InputObject $o -MemberType ScriptMethod -Name "UpdateName" -Value $fUpdateName #endregion return $o } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMLocalizationObject -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMFolder=$null $global:logIndention = $localIndent throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUTv78+LkgE9npQjip2xTpVYIv # RNCgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8Ye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LxK/u4iOh3subM # 5p/2bDqIK46J5EhWp/ShxqNR4VZhI2txp6irySb7eS6JpHHN9l+fjbrGGbJHlL9v # S3MU+KIQhbI= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Build-Publish-Module.ps1
Build-Publish-Module.ps1
Param( $Path=$null, $ApiKey=$null ) Write-Host "Starting Script ""Build-Publish-Module.ps1""" -ForegroundColor Gray -BackgroundColor White Publish-Module -Path $Path -NuGetApiKey $ApiKey Write-Host "Finished Script ""Build-Publish-Module.ps1""" -ForegroundColor Gray -BackgroundColor White
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMFolder.ps1
Matrix42.EMPSSDK.EMFolder.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Folder # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMFolder.Helper.ps1" function New-EMFolder { <# .SYNOPSIS Creates a local folder-object. .DESCRIPTION Creates a local folder-object. There is just this one function for Folder-Creation, the FolderType will let decide you, in which section of EM the folder will be created. .EXAMPLE New-EMFolder -FolderType Rolloutplans -DeFolderName "Deutscher Name" -EnFolderName "English Name" Creates a new folder object for the rolloutplan view. .EXAMPLE New-EMFolder -FolderType Rolloutplans -DeFolderName "Deutscher Name" -EnFolderName "English Name" -ParentFolderId 5324 Creates a new folder object for the rolloutplan view as sub-folder of an existing folder. .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$false,Position=0)] [ValidateSet('Rolloutplans','Sequences','Variables','SccmPackages','Applications','Locations','Roles','Computergroups','UpdateList','OsdConfig','None')] [string]$FolderType='None', [Parameter(Mandatory=$false,Position=1)] [string]$DeFolderName, [Parameter(Mandatory=$false,Position=2)] [string]$EnFolderName, [Parameter(Mandatory=$false,Position=3)] [int]$ParentFolderId=0 ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a folder" -Component New-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose if([string]::IsNullOrEmpty($DeFolderName) -and [string]::IsNullOrEmpty($EnFolderName)) { throw "You have to provide a name for the new folder object" } if($FolderType -ieq "none") { throw "You have to provide a type for the new folder object" } Add-KabompoLogLine -Message "Create API object" -Component New-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose $EMApiFolder = New-Object -TypeName Matrix42.EM.Contract.Container.v2.Folder $EMApiFolder.De_Name = $DeFolderName $EMApiFolder.En_Name = $EnFolderName $EMApiFolder.ParentID = $ParentFolderId $EMApiFolder.Type = $FolderType Add-KabompoLogLine -Message "Create PS object from API object" -Component New-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMFolder = New-EMFolderObject -ParentFolderId $ParentFolderId -DeFolderName $DeFolderName -EnFolderName $EnFolderName -FolderType $FolderType -EMApiFolder $EMApiFolder $global:logIndention-- Add-KabompoLogLine -Message "Finished creating a folder of type $FolderType with name $EnFolderName" -Component New-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMFolder } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMFolder -Type 3 -Verbose:$DoVerbose $EMFolder=$null $global:logIndention = $localIndent throw $_.Exception } } function Get-EMFolder { <# .SYNOPSIS Load a folder from the EM-Database. .DESCRIPTION Load a folder from the EM-Database. You can define a Name and Type to search for, or you can use the ID of the folder alternativly. .EXAMPLE Get-EMFolder -FolderType Rolloutplans -FolderName "German or English name" Search for a folder by name and type in the Rolloutplan-View. The Commandlet will search for the folder dependend on the language you have configured during the login (The search for an english name will fail, if you are connected with "de" language). .EXAMPLE Get-EMFolder -FolderType Rolloutplans -FolderName "English na*" Search for a folder by its english name in the Rolloutplan-View and use an asterisk (*) as placeholder for the last two character. .EXAMPLE Get-EMFolder -FolderType Rolloutplans -FolderName "English nam_" Search for a folder by its english name in the Rolloutplan-View and use an underline (_) as placeholder for the last character. .EXAMPLE Get-EMFolder -FolderType None -FolderName "English name" Search for a folder by its english name in all views. .EXAMPLE Get-EMFolder -FolderType Rolloutplans -FolderId 4319 Search for a folder by name and type in the Rolloutplan-View. .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$false,Position=1)] [ValidateNotNullorEmpty()] [int]$FolderId=0, [Parameter(Mandatory=$false,Position=2)] [ValidateSet('Rolloutplans','Sequences','Variables','SccmPackages','Applications','Locations','Roles','Computergroups','UpdateList','OsdConfig','None')] [string]$FolderType='None', [Parameter(Mandatory=$false,Position=3)] [string]$FolderName ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start loading a folder from EM." -Component Get-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose # If folder id is given, lets directly query for it if($FolderId -ne 0) { Add-KabompoLogLine -Message "The folder ID ""$FolderId"" is given. Try to find the folder by the ID and ignore type and name parameters." -Component Get-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose $result = Get-EMApiFolderLoad -EMConnection $EMConnection -FolderId $FolderId } # Try to identify a folder by its name and its type elseif(![String]::IsNullOrEmpty($FolderName) -and $FolderType -ine "None") { Add-KabompoLogLine -Message "The folder type ""$FolderType"" and name ""$FolderName"" is given. Try to find the folder by its name." -Component Get-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose $result = Get-EMApiFolderSearch -EMConnection $EMConnection -FolderType $FolderType -FolderName $FolderName } # if just the foldername is given, query all folder types elseif(![String]::IsNullOrEmpty($FolderName)) { if($FolderType -ieq "None") { $folderTypes = 'Rolloutplans','Sequences','Variables','SccmPackages','Applications','Locations','Roles','Computergroups','UpdateList','OsdConfig' Add-KabompoLogLine -Message "No folder type given. Enumerate thorugh all possible folder types." -Component Get-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose foreach($ft in $FolderTypes) { Add-KabompoLogLine -Message "Get folders for type ""$ft""" -Component Get-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose $folderResult = Get-EMApiFolderSearch -EMConnection $EMConnection -FolderType $ft -FolderName $FolderName if($folderResult -ne $null) { $result += ,$folderResult } #$result += ,$EMConnection.EMApiConnection.Folder_Search($ft, $FolderName) } } } else { throw "You have to declare an ID or the name/type of the folder you want to search for." } $EMApiFolder = @() # Single result returned from EM-Api. We can directly add it to the result array #if($result.GetType().FullName -ieq "Matrix42.EM.Contract.Container.v2.Folder" -and $result.ID -ne 0 -and $result.Type -ine "none") if($result.Id.Count -eq 1) { $EMApiFolder += , $result } # Multiple results where returned. Lets enumerate them them, extract the folders and add them to the result array else { foreach($r in $result) { if($r.Folders.Count -eq 0) { continue } elseif($r.Folders.Count -ge 1) { foreach($f in $r.Folders.Values) { if($f -ne 0 -and $f -ine "none") {$EMApiFolder += ,$f } } } } } if($EMApiFolder.Count -eq 0) { Add-KabompoLogLine -Message "No folders received" -Component Get-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "Successful read out $($EMApiFolder.Count) folder with ID ""$($EMApiFolder.ID)""" -Component Get-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Now lets go throught the array and convert them to native powershell objects foreach($i in $EMApiFolder) { if($i.ID -eq 0 -and $i.Type -ieq "none") { break } $global:logIndention++ $EMFolder = New-EMFolderObject -Id $i.ID -ParentId $i.ParentID -FolderType $i.Type -EnFolderName $i.En_Name -DeFolderName $i.De_Name -EMApiFolder $i -EMConnection $EMConnection $global:logIndention-- $EMFolderList += ,$EMFolder } } Add-KabompoLogLine -Message "Finished loading ""$($EMFolderList.Count)"" folder(s) from EM." -Component Get-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return the folder array. If there is just one object in the array, powershell will automatically convert this to a single object return $EMFolderList } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Get-EMFolder -Type 3 -Verbose:$DoVerbose $EMFolder=$null $global:logIndention = $localIndent throw $_.Exception } } function Save-EMFolder { <# .SYNOPSIS Save an EM-Folder to the EM-Database. .DESCRIPTION Save an EM-Folder to the EM-Database. .EXAMPLE Save-EMFolder -EMConnection $conn -EMFolder $folder Save the given Folder object to EM. The function will end in an exception when the the folder already with the same english OR german name in the same structure (parent-folder). .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] $EMFolder=$null ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start saving folder to EM." -Component Save-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose if($EMFolder.FolderType -ieq "applications") { throw "It is not possible to create a SCCM-Application folder with the SDK (Should be created with SCCM and synchronized automatically)." } if($EMFolder.FolderType -ieq "sccmpackages") { throw "It is not possible to create a SCCM-Package folder with the SDK (Should be created with SCCM and synchronized automatically)." } # Check for parent folder. $global:logIndention++ if(!(Test-EMFolder -EMConnection $EMConnection -FolderId $EMFolder.ParentFolderId -FolderType $EMFolder.FolderType -Verbose:$DoVerbose)) { throw "Given parent folder does not exist." } $global:logIndention-- # Check if folder with same name exist $existingFolder = $null $global:logIndention++ # Get folder with same localized name and type (Get-EMFolder will just return a folder, when you specify the name in the language which you have used to setup the connection) if($conn.Language -eq "de") { $existingFolder = Get-EMFolder -EMConnection $conn -FolderType $EMFolder.FolderType -FolderName $EMFolder.FolderLocalizedNames.GetName("de-DE") } else { $existingFolder = Get-EMFolder -EMConnection $conn -FolderType $EMFolder.FolderType -FolderName $EMFolder.FolderLocalizedNames.GetName("en-US") } $global:logIndention-- # When folder exist, check if the parent ID is matching if($existingFolder -ne $null) { if($existingFolder.ParentFolderId -eq $EMFolder.ParentFolderId) { Add-KabompoLogLine -Message "A folder with same name already exist with the same parent ID. Skipping folder creation." -Component Save-EMFolder -Type 2 -LogLevel 2 -Verbose:$DoVerbose $objId = $existingFolder.Id } } # If folder does not exist, create folder if($objId -eq $null) { $global:logIndention++ $objId = Save-EMApiFolder -EMConnection $EMConnection -EMFolder $EMFolder -Verbose:$DoVerbose $global:logIndention-- } # Save Id to local object $EMFolder.EMApiFolder.ID = $objId $EMFolder.Id=$objId Add-KabompoLogLine -Message "Finished saving folder to EM." -Component Save-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMFolder } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Save-EMFolder -Type 3 -Verbose:$DoVerbose $global:logIndention = $localIndent throw $_.Exception } } function Test-EMFolder { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] [int]$FolderId=$null, [Parameter(Mandatory=$true,Position=2)] [ValidateNotNullorEmpty()] [ValidateSet('Rolloutplans','Sequences','Variables','SccmPackages','Applications','Locations','Roles','Computergroups','UpdateList','OsdConfig')] [string]$FolderType=$null ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start testing folder." -Component Test-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose $ret = $false if($FolderId -eq 0) { Add-KabompoLogLine -Message "Root folder is given. Skipping test." -Component Test-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose $ret = $true } else { Add-KabompoLogLine -Message "Get folder by its ID." -Component Test-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMFolderToTest = Get-EMFolder -EMConnection $EMConnection -FolderId $FolderId -FolderType $FolderType -Verbose:$DoVerbose $global:logIndention-- if($EMFolderToTest -eq $null -or $EMFolderToTest.FolderType -eq "None") { Add-KabompoLogLine -Message "No folder to test given or folder type is invalid. Returning false." -Component Test-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose } elseif($EMFolderToTest -ne $null -and $FolderType -ne $EMFolderToTest.FolderType) { Add-KabompoLogLine -Message "The folder which was returned doesn't match the given folder type. Returning false." -Component Test-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "The given FolderId ""$FolderId"" was found and type is matching." -Component Test-EMFolder -Type 1 -LogLevel 1 -Verbose:$DoVerbose $ret = $true } ### Hint: NO NEED TO CHECK IF FOLDER WITH SAME NAME EXIST WITH IDENTICAL PARENTID. THIS WILL DONE BY API AND RESULT IN AN EXCEPTION ### } Add-KabompoLogLine -Message "Finished testing folder. Result = $ret." -Component Test-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $ret } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Test-EMFolder -Type 3 -Verbose:$DoVerbose $global:logIndention = $localIndent throw $_.Exception } } function Remove-EMFolder { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] $EMFolder=$null, [Parameter(Position=2)] [switch]$Recurse ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start removing folder from EM." -Component Remove-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose if($EMFolder.FolderType -ieq "applications") { throw "It is not possible to delete a SCCM-Application folder with the SDK (Should be created with SCCM and synchronized automatically)." } if($EMFolder.FolderType -ieq "sccmpackages") { throw "It is not possible to delete a SCCM-Package folder with the SDK (Should be created with SCCM and synchronized automatically)." } # Check if folder exist in EM. $global:logIndention++ $checkFolder = Test-EMFolder -EMConnection $EMConnection -FolderId $EMFolder.Id -FolderType $EMFolder.FolderType -Verbose:$DoVerbose $global:logIndention-- if(!($checkFolder)) { Add-KabompoLogLine -Message "Given folder does not exist in EM Database." -Component Remove-EMFolder -Type 2 -LogLevel 1 -Verbose:$DoVerbose } else { $global:logIndention++ if($Recurse) { Remove-EMApiFolder -EMConnection $EMConnection -EMFolder $EMFolder -Recurse $true -Verbose:$DoVerbose } else { Remove-EMApiFolder -EMConnection $EMConnection -EMFolder $EMFolder -Recurse $false -Verbose:$DoVerbose } $global:logIndention-- } Add-KabompoLogLine -Message "Finished removing folder from EM." -Component Remove-EMFolder -Type 1 -LogLevel 2 -Verbose:$DoVerbose } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Remove-EMFolder -Type 3 -Verbose:$DoVerbose $global:logIndention = $localIndent throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU3Kkd5uZb01bE0TDWDNpIZ4gX # pBugggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVB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ivShK9 # DbOXBd5EDBX6NisD3MFQAfGhEV0U5eK9J0tUviuEXg+mw3QFCu+Xw4kisR93873N # Q9TxTKk/tYuEr2Ty0BQhMYICNTCCAjECAQEwgZMwfzELMAkGA1UEBhMCVVMxHTAb # BgNVBAoTFFN5bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FIbFis/R9HD1G0gwBh/Jf0J2lAOVMA0GCSqGSIb3DQEBAQUABIIBADu0IZ6w6nA/ # BGxpYln0tPkH0vwAgEHQhs0f8LHyt9X4Rc1w15JB5DHKx5lSgiooZWadnOTeGSFt # RjUVC8YYf80YZieu265ro8i5PaMEY+0bi0LldC6o6OIEMr8e0Rkru1dpCn9Fc57Z # XZPLtD+4fQ9dWNUbNcVv6b4DUv9kYwBWbSHTaNwozjLheIpP75WUNyggx9/feCt1 # M8Fmh8yXqi349jB0kbzBhYLKisLMAzB4mQDQvossuJNln2HbvHD0mfNf8/KTqDjU # EcdJQ7/d60VM8GlDI4pPOWKfo9zwA1eqY2a2k9DTAsp2oi6llD0EpDt8+Uqeymin # ZMX7Eym43Kw= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMReleasegroups.ps1
Matrix42.EMPSSDK.EMReleasegroups.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Releasegroups # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMReleasegroups.Helper.ps1" function Get-EMReleasegroup { <# .SYNOPSIS Load a releasegroup from the EM-Database. .DESCRIPTION Load a releasegroup from the EM-Database. You can define the Name of the group to filter the result. Otherwise all releasegroups will be returned. .EXAMPLE Get-EMReleasegroup .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] $EMConnection=$null, [Parameter(Mandatory=$false,Position=1)] [int]$ReleasegroupId=0, [Parameter(Mandatory=$false,Position=2)] [string]$ReleasegroupName=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start loading a releasegroup from EM." -Component Get-EMReleasegroup -Type 1 -LogLevel 2 -Verbose:$DoVerbose $EMReleasegroupList = @() # If releasegroup id is given, lets directly query for it if($ReleasegroupId -ne 0 -and $ReleasegroupId -ne $null) { Add-KabompoLogLine -Message "The releasegroup ID ""$ReleasegroupId"" is given. Try to find the releasegroup by the ID and ignore the name parameters." -Component Get-EMReleasegroup -Type 1 -LogLevel 1 -Verbose:$DoVerbose $result = Get-EMApiReleasegroupLoad -EMConnection $EMConnection -ReleasegroupId $ReleasegroupId -Verbose:$DoVerbose } # Try to identify a releasegroup by its name and its type elseif(![String]::IsNullOrEmpty($ReleasegroupName)) { Add-KabompoLogLine -Message "The releasegroup name ""$ReleasegroupName"" is given. Try to find the releasegroup by its name." -Component Get-EMReleasegroup -Type 1 -LogLevel 1 -Verbose:$DoVerbose $result = Get-EMApiReleasegroupSearch -EMConnection $EMConnection -ReleasegroupName $ReleasegroupName -Verbose:$DoVerbose } else { throw "You have to declare the ID or the name of the releasegroup you want to search for." } if($result.Count -eq 0) { Add-KabompoLogLine -Message "No releasegroups received" -Component Get-EMReleasegroup -Type 1 -LogLevel 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "Successful read out $($result.Count) releasegroups with ID ""$($result.ID)""" -Component Get-EMReleasegroup -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Now lets go throught the array and convert them to native powershell objects foreach($i in $result) { $global:logIndention++ $EMReleasegroup = New-EMReleasegroupObject -Id $i.ID -Name $i.Name -EMApiReleasegroup $i -Verbose:$DoVerbose $global:logIndention-- $EMReleasegroupList += ,$EMReleasegroup } } Add-KabompoLogLine -Message "Finished loading ""$($EMReleasegroupList.Count)"" releasegroup(s) from EM." -Component Get-EMReleasegroup -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return the releasegroup array. If there is just one object in the array, powershell will automatically convert this to a single object return $EMReleasegroupList } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Get-EMReleasegroup -Type 3 -Verbose:$DoVerbose $EMFolder=$null throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUGH4+HrQb0vVq/bliWK7XNSEO # eJKgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGS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MYICNTCCAjECAQEwgZMwfzELMAkGA1UEBhMCVVMxHTAb # BgNVBAoTFFN5bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FLUq+ECECC9szWEyC7DaaxSAqlJaMA0GCSqGSIb3DQEBAQUABIIBAJIvm38Q8ltD # 1/p5a2hSvnfnuNoIhz5yy0NekjVpnZyiS96yQqJABu499zatDhwUDjJ/OA8z8bQy # WkgVjnpDbi49+v4QRctOZOtJOLGYv2KyG03XynN3YJTvJ0g3kEpdg3lpsKLOZnOL # uLaKioqhMvs1kClLMsjawW2zawjtNJzIp/+eSyZxJTqC3jJJvDFUwu7FK8Yjf/w6 # MFsBocY4jbiwOD5gTg2qL5jp3RXeENNh0fBJEFWQo7r6tVVvJ8lQ0HwZeQqxj/hL # X5DmCv3XhxaS9Rs4wJuD775sZFZBz5xYPqAG2vLC09SiN0bOK5LHIvHKDMWVyUB0 # ncK0Ul+t/ug= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMComputer.ps1
Matrix42.EMPSSDK.EMComputer.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Computer # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMComputer.Helper.ps1" function New-EMComputer { <# .SYNOPSIS Creates a local Computer object which you can edit and transfer to the "Matrix42 Enterprise Manager for SCCM" (EM) via the WebService Interface. .DESCRIPTION Creates a local Computer object which you can edit and transfer to the "Matrix42 Enterprise Manager for SCCM" (EM) via the WebService Interface. Use the Save-EMComputer method to transfer the information to the EM-Server. To install this computer within an OSD, the computer must exist in SCCM with the same MAC-Address. .EXAMPLE New-EMComputer -Hostname "PC01" -SccmSiteCode "MUC" -MACAddresses "001122334455" Will create a EM-Computer Object for the Computer "PC01". This Computer is associated to the SCCM Sitecode "MUC" and will have the MAC-Address "001122334455". .EXAMPLE New-EMComputer -Hostname "PC01" -SccmSiteCode "MUC" -MACAddresses "001122334455", "112233445566" Will create a EM-Computer Object for the Computer "PC01". This Computer is associated to the SCCM Sitecode "MUC" and will have the two MAC-Address "001122334455", "112233445566". .EXAMPLE New-EMComputer -Hostname "PC01" -SccmSiteCode "MUC" -Archived $true -MACAddresses "001122334455" Will create a EM-Computer Object for the Computer "PC01". This Computer is associated to the SCCM Sitecode "MUC" and will have the MAC-Address "001122334455". This computer will be flagged as "Archived" in EM. .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [string]$Hostname, [Parameter(Mandatory=$true,Position=1)] [string]$SccmSiteCode, [Parameter(Mandatory=$false,Position=2)] [bool]$Archived = $false, [Parameter(Mandatory=$true,Position=3)] [string[]]$MACAddresses ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a local EMComputer object" -Component New-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose # check for the length of the computername if($Hostname.Length -gt 15) { throw "Hostname is too long. Please do not use more than 15 characters." } # Create sequence object $EMApiComputer = New-Object -TypeName Matrix42.EM.Contract.Container.v2.Computer $EMApiComputer.Hostname = $Hostname $EMApicomputer.SccmSitecode = $SccmSiteCode $EMApiComputer.Archived = $Archived $EMApiComputer.MacAdresses = $MacAddresses # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object" -Component New-EMComputer -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMComputer = New-EMComputerObject -Hostname $Hostname -Archived $Archived -SccmSiteCode $SccmSiteCode -MACAddresses $MacAddresses -EmApiComputer $EMApiComputer -Verbose:$DoVerbose $global:logIndention-- Add-KabompoLogLine -Message "Finished creating a local EMComputer object with name $Hostname" -Component New-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMComputer } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMComputer -Type 3 -Verbose:$DoVerbose $EMComputer=$null throw $_.Exception } } function Get-EMComputer { <# .SYNOPSIS Load a computer object from "Matrix42 Enterprise Manager for SCCM" (EM) via the WebService Interface. .DESCRIPTION Load a computer object from "Matrix42 Enterprise Manager for SCCM" (EM) via the WebService Interface. .EXAMPLE Get-EMComputer -EMConnection $conn -Hostname "PC01" Will load the information of computer "PC01" from the EM-Database. You have to create the connection object before. .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [string]$Hostname ) Add-KabompoLogLine -Message "Start loading a computer from EM." -Component Get-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $result = Get-EMApiComputerSearch -EMConnection $EMConnection -Hostname $Hostname -Verbose:$DoVerbose $EMComputer = $null if($result -ne $null) { $global:logIndention++ $EMComputer = New-EMComputerObject -Hostname $result.Hostname -Archived $result.Archived -Domain $result.Domain -LDAPPath $result.LdapPath -MACAddresses $result.MacAdresses -MainUser $result.MainUser -SccmGuid $result.SccmGuid -LastSccmHWScan $result.SccmLastHwScan -SccmSiteCode $result.SccmSitecode -SccmVersion $result.SccmVersion -EMVersion $result.EmVersion -SerialNumber $result.Serial -SpecialValue1 $result.SpecialValue1 -SpecialValue2 $result.SpecialValue2 -EmApiComputer $result -Verbose:$DoVerbose $global:logIndention-- } Add-KabompoLogLine -Message "Finished loading a computer from from EM-Database." -Component Get-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMComputer } catch { $EMComputer = $null Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Get-EMComputer -Type 3 -Verbose:$DoVerbose throw $_.Exception } } function Test-EMComputer { <# .SYNOPSIS Test if a computer exist in the "Matrix42 Enterprise Manager for SCCM" (EM) Database. .DESCRIPTION Test if a computer exist in the "Matrix42 Enterprise Manager for SCCM" (EM) Database. .EXAMPLE Test-EMComputer -EMConnection $conn -Hostname "PC01" Will check, if computer "PC01" exist in the EM-Database. You have to create the connection object before. .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] [string]$Hostname=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start testing computer." -Component Test-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose $ret = $false Add-KabompoLogLine -Message "Get computer by it's hostname ""$Hostname""." -Component Test-EMComputer -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMComputerToTest = Get-EMComputer -EMConnection $EMConnection -Hostname $Hostname -Verbose:$DoVerbose $global:logIndention-- if($EMComputerToTest -eq $null) { Add-KabompoLogLine -Message "No computer found. Returning false." -Component Test-EMComputer -Type 1 -LogLevel 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "The given Hostname was found." -Component Test-EMComputer -Type 1 -LogLevel 1 -Verbose:$DoVerbose $ret = $true } Add-KabompoLogLine -Message "Finished testing for computer. Result = $ret." -Component Test-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $ret } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Test-EMComputer -Type 3 -Verbose:$DoVerbose throw $_.Exception } } function Save-EMComputer { <# .SYNOPSIS Store a previously created computer object in the "Matrix42 Enterprise Manager for SCCM" (EM) Database. .DESCRIPTION Store a previously created computer object in the "Matrix42 Enterprise Manager for SCCM" (EM) Database. The connection and the Computer object must be created before. The function will check if the computer already exist and deny the creation of the Computer, if a computer object exist in the EM-Database with the same Hostname. .EXAMPLE Save-EMComputer -EMConnection $conn -EMComputer $computer Will create the computer stored in the variable $computer into the EM-Database, which is specified in the $conn variable. .EXAMPLE Save-EMComputer -EMConnection $conn -EMComputer $computer -EMGroupId 1 Will create the computer stored in the variable $computer into the EM-Database, which is specified in the $conn variable. The computer will be automatically added to the computergroup with the ID 1. .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] $EMComputer=$null, [Parameter(Mandatory=$false,Position=2)] [ValidateNotNullorEmpty()] $EMGroupId=0 ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start saving a computer to EM." -Component Save-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Check for existing computer. Add-KabompoLogLine -Message "Check if computer already exist in EM Database." -Component Save-EMComputer -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $exist = Test-EMComputer -EMConnection $EMConnection -Hostname $EMComputer.Hostname -Verbose:$DoVerbose $global:logIndention-- if($exist) { throw "The computer already exists. Computer will not be created." } # Save computer to EM Database Add-KabompoLogLine -Message "Save the given computer to EM-Database." -Component Save-EMComputer -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $objId = Save-EMApiComputer -EMConnection $EMConnection -EMComputer $EMComputer -Verbose:$DoVerbose $global:logIndention-- #------------------------------------------------------------------------------ # Normally we would write the computers object-id back to the object. # But a computer doesn't have a ID. # The computers ID is the hostname. #------------------------------------------------------------------------------ # Add computer to a group if($EMGroupId -ne 0) { Add-EMComputerApiComputerToGroup -EMConnection $EMConnection -EMComputer $EMComputer -EMGroupId $EMgroupId } Add-KabompoLogLine -Message "Finished saving a computer to EM." -Component Save-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMComputer } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Save-EMComputer -Type 3 -Verbose:$DoVerbose throw $_.Exception } } function Remove-EMComputer { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] $EMComputer=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start removing a computer to EM." -Component Remove-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Check for existing computer. Add-KabompoLogLine -Message "Check if computer exist in EM Database." -Component Remove-EMComputer -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $exist = Test-EMComputer -EMConnection $EMConnection -Hostname $EMComputer.Hostname -Verbose:$DoVerbose $global:logIndention-- if($exist) { # Save computer to EM Database Add-KabompoLogLine -Message "Remove computer from EM-Database." -Component Remove-EMComputer -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $objId = Remove-EMApiComputer -EMConnection $EMConnection -EMComputer $EMComputer -Verbose:$DoVerbose $global:logIndention-- } Add-KabompoLogLine -Message "Finished removing a computer from EM." -Component Remove-EMComputer -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMComputer } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Remove-EMComputer -Type 3 -Verbose:$DoVerbose throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck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rRASm5hhufcIyA # +tsDYJBqaoxmHXbWZVvIF3S9ja8qfQZkkBCLZXJ5m8g+D63TO70NHs64qMwr7DXV # bnhY3GPh+4IH9fSQL4nTTWnmEL4hDEIw6oM/9QafTcY26BowVk9n2NVty17uzEXd # NEHx0Crs7hk+O2Q7/w550/327f74Gpw1vIrHPh1CvH6AG6mGESqvkTavyQ7Ycryw # rYm04IyJ/s4= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMRolloutplans.ps1
Matrix42.EMPSSDK.EMRolloutplans.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Rolloutplans # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- . "$($PSScriptRoot)\Matrix42.EMPSSDK.EMRolloutPlans.Helper.ps1" function New-EMRolloutplan { Param ( [Parameter(Mandatory=$true,Position=0)] [string]$Caption, [Parameter(Mandatory=$true,Position=1)] [string]$ReleasegroupId, [Parameter(Mandatory=$false,Position=2)] [string]$ParentFolderId=0, [Parameter(Mandatory=$false,Position=3)] [string]$DeDescription, [Parameter(Mandatory=$false,Position=4)] [string]$EnDescription, [Parameter(Mandatory=$false, Position=6)] $UserAccount=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a local EMRolloutplan object" -Component New-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose if([string]::IsNullOrEmpty($DeDescription)) { Add-KabompoLogLine -Message "No german description given. Set german description to caption" -Component New-EMRolloutplan -Type 2 -LogLevel 1 -Verbose:$DoVerbose $DeDescription = $Caption } if([string]::IsNullOrEmpty($EnDescription)) { Add-KabompoLogLine -Message "No english description given. Set english description to caption" -Component New-EMRolloutplan -Type 2 -LogLevel 1 -Verbose:$DoVerbose $EnDescription = $Caption } # Create sequence object $EMApiRolloutPlan = New-Object -TypeName Matrix42.EM.Contract.Container.v2.RolloutPlan $EMApiRolloutPlan.Name = $Caption $EMApiRolloutPlan.ID_ReleaseGroup = $ReleasegroupId $EMApiRolloutPlan.ID_Folder = $ParentFolderId $EMApiRolloutPlan.De_Description = $DeDescription $EMApiRolloutPlan.En_Description = $EnDescription $EMApiRolloutPlan.Version = 1 $EMApiRolloutPlan.Account = $UserAccount $EMApiRolloutPlan.WaitOnTask = $True # Create EM-PS Object Add-KabompoLogLine -Message "Create PS object from API object" -Component New-EMRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose $EMRolloutplan = New-EMRolloutplanObject -Caption $Caption -ReleaseGroupId $ReleasegroupId -ParentFolderId $ParentFolderId -DeDescription $DeDescription -EnDescription $EnDescription -Version 1 -UserAccount $UserAccount -EMApiRolloutplan $EMApiRolloutPlan -Verbose:$DoVerbose Add-KabompoLogLine -Message "Finished creating a local EMRolloutplan object with name $RolloutPlanName" -Component New-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMRolloutplan } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMRolloutplan -Type 3 -Verbose:$DoVerbose $EMRolloutplan=$null throw $_.Exception } } function Get-EMRolloutplan { <# .SYNOPSIS .DESCRIPTION .EXAMPLE .EXAMPLE .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$false,Position=1)] [ValidateNotNullorEmpty()] [int]$RolloutplanId=0, [Parameter(Mandatory=$false,Position=3)] [string]$RolloutplanName ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start loading a Rolloutplan from EM." -Component Get-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose # If folder is given, lets directly query for it if($RolloutplanId -ne 0) { Add-KabompoLogLine -Message "The Rolloutplan ID ""$RolloutplanId"" is given. Try to find the Rolloutplan by the ID and ignore name parameters." -Component Get-EMRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose $result = $EMConnection.EMApiConnection.RolloutPlan_Load($RolloutplanId) } # Try to identify a folder by its name and its type elseif(![String]::IsNullOrEmpty($RolloutplanName)) { Add-KabompoLogLine -Message "The foldername ""$RolloutplanName"" is given. Try to find the folder by its name." -Component Get-EMRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose $result = $EMConnection.EMApiConnection.RolloutPlan_Search($RolloutplanName) } else { throw "You have to declare an ID or the name of the rolloutplan you want to search for." } $EMApiRolloutplan = @() # Single result returned from EM-Api. We can directly add it to the result array if($result.GetType().FullName -ieq "Matrix42.EM.Contract.Container.v2.RolloutPlan" -and $result.ID -ne 0 -and $result.Type -ine "none") { $EMApiRolloutplan += , $result } # Multiple results where returned. Lets enumerate them them, extract the rolloutplans and add them to the result array else { foreach($r in $result) { if($result.RolloutPlans.Count -eq 0) { continue } elseif($result.RolloutPlans.Count -ge 1) { foreach($rp in $r.RolloutPlans.Values) { if($rp.ID -ne 0) {$EMApiRolloutplan += ,$rp } } } } } $EMApiRolloutplanList = @() if($EMApiRolloutplan.Count -eq 0) { Add-KabompoLogLine -Message "No Rolloutplans received" -Component Get-EMRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "Successful read out $($EMApiRolloutplan.Count) rolloutplans with ID ""$($EMApiRolloutplan.ID)""" -Component Get-EMRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose # Now lets go throught the array and convert them to native powershell objects foreach($i in $EMApiRolloutplan) { $EMRolloutplan = New-EMRolloutplanObject -Id $i.ID -Caption $i.Name -ReleaseGroupId $i.ID_ReleaseGroup -ParentFolderId $i.ID_Folder -EnDescription $i.En_Description -DeDescription $i.De_Description -Version $i.Version -UserAccount $i.Account -EMApiRolloutplan $i -Verbose:$DoVerbose $EMRolloutplanList += ,$EMRolloutplan } } Add-KabompoLogLine -Message "Finished loading ""$($EMRolloutplanList.Count)"" rolloutplan(s) from EM." -Component Get-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose # return the folder array. If there is just one object in the array, powershell will automatically convert this to a single object return $EMRolloutplanList } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Get-EMRolloutplan -Type 3 -Verbose:$DoVerbose $EMFolder=$null throw $_.Exception } } function Save-EMRolloutplan { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] $EMRolloutplan=$null ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start saving a EMRolloutplan to EM." -Component Save-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Check for parent folder. $global:logIndention++ if(!(Test-EMFolder -EMConnection $EMConnection -FolderId $EMRolloutPlan.ParentFolderId -FolderType Rolloutplans -Verbose:$DoVerbose)) { throw "Given parent folder does not exist" } $global:logIndention-- # Save rolloutplan to EM Database and get retreived ID $global:logIndention++ $objId = Save-EMApiRolloutplan -EMConnection $EMConnection -EMRolloutplan $EMRolloutplan -Verbose:$DoVerbose $global:logIndention-- # Write ID to local object if($objId -ne $null) { $EMRolloutplan.EMApiRolloutplan.ID = $objId $EMRolloutplan.Id=$objId } else { throw "Failed to retrieve ID from newly created object" } Add-KabompoLogLine -Message "Finished saving folder to EM." -Component Save-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $EMRolloutplan } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Save-EMRolloutplan -Type 3 -Verbose:$DoVerbose throw $_.Exception } } function Test-EMRolloutplan { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] [int]$RolloutplanId=0 ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start testing Rolloutplan." -Component Test-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose $ret = $false if($RolloutplanId -eq 0) { Add-KabompoLogLine -Message "Root folder is given. Skipping test." -Component Test-EMRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose $ret = $true } else { Add-KabompoLogLine -Message "Get Rolloutplan by its ID." -Component Test-EMRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose $global:logIndention++ $EMRolloutplanToTest = Get-EMRolloutplan -EMConnection $EMConnection -RolloutplanId $RolloutplanId -Verbose:$DoVerbose $global:logIndention-- if($EMRolloutplanToTest -eq $null) { Add-KabompoLogLine -Message "No Rolloutplan found. Returning false." -Component Test-EMRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose } else { Add-KabompoLogLine -Message "The given RolloutplanId was found." -Component Test-EMRolloutplan -Type 1 -LogLevel 1 -Verbose:$DoVerbose $ret = $true } ### Hint: NO NEED TO CHECK IF ROLLOUTPLAN WITH SAME NAME EXIST WITH IDENTICAL PARENTID. THIS WILL DONE BY API AND RESULT IN AN EXCEPTION ### } Add-KabompoLogLine -Message "Finished testing Rolloutplan. Result = $ret." -Component Test-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose return $ret } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Test-EMRolloutplan -Type 3 -Verbose:$DoVerbose throw $_.Exception } } function Remove-EMRolloutplan { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] [ValidateNotNullorEmpty()] $EMRolloutplan=$null ) try { $localIndent = $global:logIndention # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start removing rolloutplan from EM." -Component Remove-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Check if rolloutplan exist in EM. $global:logIndention++ $checkRolloutplan = Test-EMRolloutplan -EMConnection $EMConnection -RolloutplanId $EMRolloutplan.Id -Verbose:$DoVerbose $global:logIndention-- if(!($checkRolloutplan)) { Add-KabompoLogLine -Message "Given rolloutplan does not exist in EM Database." -Component Remove-EMRolloutplan -Type 2 -LogLevel 1 -Verbose:$DoVerbose } else { $global:logIndention++ Remove-EMApiRolloutplan -EMConnection $EMConnection -EMRolloutplan $EMRolloutplan -Verbose:$DoVerbose $global:logIndention-- } Add-KabompoLogLine -Message "Finished removing rolloutplan from EM." -Component Remove-EMRolloutplan -Type 1 -LogLevel 2 -Verbose:$DoVerbose } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Remove-EMRolloutplan -Type 3 -Verbose:$DoVerbose $global:logIndention = $localIndent throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUukTGP5zAD6r6sNgbwmM8JV1n # OsSgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwE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QFCu+Xw4kisR93873N # Q9TxTKk/tYuEr2Ty0BQhMYICNTCCAjECAQEwgZMwfzELMAkGA1UEBhMCVVMxHTAb # BgNVBAoTFFN5bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FLGHwyC7k2S50KkICKltf1fRWrV6MA0GCSqGSIb3DQEBAQUABIIBAJXVzTMJTDM7 # YJq8xQQj01G32ryiN1zED3fmxbDzA23LWE9f8WPqb4CYevtPufGIJBkYnMVZw5zW # dVbvZfIvWcrEaS0zgOtdsHKCOp1h4lqJCGBc+y2RzyC1zl0t3zueGsCzI7HQTSDJ # EGOx0Evo5mlI76+AtdLJDDcquAW/YOK52rpoT9JRCB86fXMU59V05Q/3msmq2YC7 # Vk1T/l5EtEqDtIf+GxtDdZg451Wwz8+rwcReW5B7yAepWvRxYdjHlLn8sZI/Gpn/ # xh80FMg5/0w+TvrVn4RgXOrULz/BuuIr4XW73YowUeVC3JbpUDvLgmwbCnk2kcEA # 7TaoGniAzl0= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMSequences.Helper.ps1
Matrix42.EMPSSDK.EMSequences.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Sequences # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- #Create an EM-Sequence Powershell Object (PSObject) function New-EMSequenceObject { Param ( [int]$Id = 0, [string]$SequenceName, [int]$Version, [string]$UserAccount, [int]$ParentFolderId = 0, [Matrix42.EM.Contract.Container.v2.Sequence]$EMApiSequence ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating a new internal EPPSSDK EMSequence-Object with following parameter" -Component New-EMSequenceObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Id: $Id" -Component New-EMSequenceObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SequenceName: $SequenceName" -Component New-EMSequenceObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Version: $Version" -Component New-EMSequenceObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...UserAccount: $UserAccount" -Component New-EMSequenceObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ParentFolderId: $ParentFolderId" -Component New-EMSequenceObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Create the object $o = New-Object -TypeName PSCustomObject # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Id" -Value $Id Add-Member -InputObject $o -MemberType NoteProperty -Name "SequenceName" -Value $SequenceName Add-Member -InputObject $o -MemberType NoteProperty -Name "Version" -Value $Version Add-Member -InputObject $o -MemberType NoteProperty -Name "UserAccount" -Value $UserAccount Add-Member -InputObject $o -MemberType NoteProperty -Name "ParentFolderId" -Value $ParentFolderId Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiSequence" -Value $EMApiSequence Add-Member -InputObject $o -MemberType NoteProperty -Name "EMActionList" -Value $null # Initialize empty List for actions $o.EMActionList = @() # Get the current parent folder of the API object and overwrite given parent ID if($EMApiSequence -ne $null) { $ParentFolderId = $EMApiSequence.ID_Folder } #region Function to add one or more EMActions to the current sequence $fAddAction = { <# .SYNOPSIS Adds an action to the current sequence. .DESCRIPTION Adds an action to the current sequence. With this function you just add an action to the local sequence object. To send it to the EM-Server you have to use the "Save()" Method. .EXAMPLE AddAction($EMAction) .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $Action=$null, [Parameter(Mandatory=$false,Position=1)] [switch]$Verbose=$false ) try { $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start adding an action to sequence" -Component "EMSequence.AddAction" -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Leave function if no action is given if($Action -eq $null) { throw "You have to provide an action" } # check if the right object is given if(!$Action.PSObject.TypeNames.Contains("EMAction")) { throw "You must provide an object from type ""EMAction""" } if($this.EMActionList.Contains($Action)) { Add-KabompoLogLine -Message "Selected action ""$($Action.EnActionName)"" is already in list." -Component "EMSequence.AddAction" -Type 2 -LogLevel 1 -Verbose:$DoVerbose } else { $this.EMActionList += $Action Add-KabompoLogLine -Message "Added action to list. Currently there are ""$($this.EMActionList.Count)"" Actions in list." -Component "EMSequence.AddAction" -Type 1 -LogLevel 1 -Verbose:$DoVerbose } # Sync conditions to EMApiObject $this.EMApiSequence.Actions.Clear() foreach($a in $this.EMActionList) { $this.EMApiSequence.Actions.Add($a.EMApiAction) } Add-KabompoLogLine -Message "Finished adding action ""$($Action.EnActionName)"" to sequence ""$($this.SequenceName)""" -Component "EMSequence.AddAction" -Type 1 -LogLevel 2 -Verbose:$DoVerbose } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component EMSequence.AddAction -Type 3 -LogLevel 1 -Verbose:$DoVerbose throw $_.Exception } } Add-Member -InputObject $o -MemberType ScriptMethod -Name "AddAction" -Value $fAddAction #endregion # Get all action in the API object, convert them and add them to the local object foreach($EMApiAction in $EMApiSequence.Actions) { # Create EM-PS Object $global:logIndention++ $EMAction = Convert-EMApiActionToEMAction -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- $o.EMActionList += ,$EMAction } # Format the object Add-KabompoLogLine -Message "Add properties ""Id"", ""SequenceName"", ""Version"", ""UserAccount""" -Component New-EMSequenceObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $VisibleProperties = @("Id", "SequenceName", "Version", "UserAccount") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o # Specify the type name $o.PSObject.TypeNames.Clear() $o.PSObject.TypeNames.Add("EMSequence") Add-KabompoLogLine -Message "Finished creating a new internal EPPSSDK EMSequence-Object" -Component New-EMSequenceObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } # Will be called by "Save-EM-Sequence" and will do the .NET Save operation. Main reason for this function is to support Unit-Testing by Pester. function Save-EMApiSequence { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=0)] $EMSequence ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) # Create the updateflag which is used to notify that the sequence is newly created $UpdateFlag = New-Object -TypeName Matrix42.EM.Contract.Container.v2.UpdateFlag "New" # Save the sequence to EM Add-KabompoLogLine -Message "Write sequence with status ""New"" to EM-Database" -Component Save-EMSequence -Type 1 -Verbose:$DoVerbose $EMSequence.EMApiSequence.Status = $EMConnection.EMApiConnection.Sequences_Save($UpdateFlag, $EMSequence.EMApiSequence); # Give feedback about the result. If failed raise an exception if ($EMSequence.EMApiSequence.Status.Type -eq "Success") { Add-KabompoLogLine -Message "Successful written sequence to EM-Database with ID ""$($EMSequence.Id)""" -Component Save-EMSequence -Type 1 -Verbose:$DoVerbose return $EMSequence.EMApiSequence.Status.ID } else { $message = "{0} {1}" -f $EMSequence.EMApiSequence.Status.Message, $EMSequence.EMApiSequence.Status.SystemMessage throw $message } } function Remove-EMApiSequence { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $EMConnection=$null, [Parameter(Mandatory=$true,Position=1)] $EMSequence, [Parameter(Mandatory=$true,Position=2)] $DeleteMode = "OnlySequence" ) $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Using EM-Api to delete EMSequence from EM Database" -Component Remove-EMApiSequence -Type 1 -LogLevel 0 -Verbose:$DoVerbose $DeleteMode = [Matrix42.EM.Contract.Container.v2.Sequence+DeleteModes] $DeleteMode $result = $EMConnection.EMApiConnection.Sequences_Delete($EMSequence.Id, $DeleteMode) if($result.Type -eq "Failed") { throw "Failed to remove sequence from database. Details: $($result.SystemMessage)" } Add-KabompoLogLine -Message "Successful remove sequence with ID ""$($EMSequence.Id)"" from EM-Database." -Component Remove-EMApiSequence -Type 1 -LogLevel 0 -Verbose:$DoVerbose } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUJ4aHRXHqR5hEdFdcyVI31kYr # QtKgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw # ggEKAoIBAQDHZNuFnBatHdyRnMUJ2Y1P6k49MjD04t9S7ukWj8upP/B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W9uMR8wHQYDVQQLExZTeW1hbnRlYyBU # cnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FH5RDzoG3mKxjgmg1cKFJRFr9On/MA0GCSqGSIb3DQEBAQUABIIBAAFH/wYbESo2 # jyK2aL6UHJ7Iq4dzolacipPVZM1i2UJJcIUVC8U4Nf3HtHeGpF6COLyztPdHbDsS # uYKhBqHZCF/fYI++xgw5kDTvY1cAU/C6BxVuYj8SrrREqNcdv+71gbMvGvXOMTLT # 91VHFXkWrhf8hA49HhrxMyA9PAe15rzBW05QDV+cfageNVMP+VJtSj5DGmSDqmPs # KKq4o960BobStZmwO/pcHOG6yMSarCbivOiwVhxVHgVcctew2Ptssn6aKSG+LrWt # gQfMwJb5MP6f4Dpgtp8dV+G2eTGZCnIeUx+CVs8jsqK3h5tvH/TZze0uH19LGl5U # PomhQGNshb4= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/EMPSSDK/1.6.0.55898/Matrix42.EMPSSDK.EMActions.Helper.ps1
Matrix42.EMPSSDK.EMActions.Helper.ps1
# ---------------------------------------------------------------------------------------------------------------------- # # Project: Powershell Module for "Matrix42 Enterprise Manager for SCCM" (EMPSSDK) # Purpose: Functions that are used to manage EM Actions # Author: Koenig, David # # ---------------------------------------------------------------------------------------------------------------------- function New-EMActionObject { Param ( [int]$Id, [string]$ActionType, [string]$DeActionName, [string]$EnActionName, [bool]$ActionOnErrorResumeNext, [bool]$ConditionOnErrorResumeNext, [int]$SortKey, $EMApiAction ) # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $m = "Start creating a new EM{0}Action" -f $ActionType Add-KabompoLogLine -Message $m -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Id: $Id" -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ActionType: $ActionType" -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...Icon: $Icon" -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...DeActionName: $DeActionName" -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...EnActionName: $EnActionName" -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ActionOnErrorResumeNext: $ActionOnErrorResumeNext" -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...ConditionOnErrorResumeNext: $ConditionOnErrorResumeNext" -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose Add-KabompoLogLine -Message "...SortKey: $SortKey" -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Create the object $o = New-Object -TypeName PSCustomObject # Add object members Add-Member -InputObject $o -MemberType NoteProperty -Name "Id" -Value $Id Add-Member -InputObject $o -MemberType NoteProperty -Name "ActionType" -Value $ActionType Add-Member -InputObject $o -MemberType NoteProperty -Name "Icon" -Value $global:ActionDefaultIcons[$ActionType] Add-Member -InputObject $o -MemberType NoteProperty -Name "DeActionName" -Value $DeActionName Add-Member -InputObject $o -MemberType NoteProperty -Name "EnActionName" -Value $EnActionName Add-Member -InputObject $o -MemberType NoteProperty -Name "ActionOnErrorResumeNext" -Value $ActionOnErrorResumeNext Add-Member -InputObject $o -MemberType NoteProperty -Name "ConditionOnErrorResumeNext" -Value $ConditionOnErrorResumeNext Add-Member -InputObject $o -MemberType NoteProperty -Name "SortKey" -Value $SortKey Add-Member -InputObject $o -MemberType NoteProperty -Name "EMApiAction" -Value $EMApiAction Add-Member -InputObject $o -MemberType NoteProperty -Name "EMConditionList" -Value $null # Initialize Member-Types $o.EMConditionList = @() #region Function to add one or more EMConditions to the current action $fAddCondition = { <# .SYNOPSIS Adds an action to the current sequence. .DESCRIPTION Adds an action to the current sequence. With this function you just add an action to the local sequence object. To send it to the EM-Server you have to use the "Save()" Method. .EXAMPLE AddAction($EMAction) .NOTES .LINK https://marketplace.matrix42.com #> Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateNotNullorEmpty()] $Condition=$null ) try { Add-KabompoLogLine -Message "Start adding a condition to action" -Component "EMAction.AddCondition" -Type 1 -LogLevel 2 -Verbose:$DoVerbose # Leave function if no condition is given if($Condition -eq $null) { throw "You have to provide a condition" } # check if the right object is given if(!$Condition.PSObject.TypeNames.Contains("EMCondition")) { throw "You must provide a sequence from type ""EMCondition""" } if($this.EMConditionList.Contains($Condition)) { Add-KabompoLogLine -Message "Selected condition ""$($Condition.EnConditionName)"" is already in list." -Component "EMAction.AddCondition" -Type 2 -Verbose:$DoVerbose } else { $this.EMConditionList += $Condition } # Sync conditions to EMApiObject $this.EMApiAction.Conditions.Clear() foreach($c in $this.EMConditionList) { $this.EMApiAction.Conditions.Add($c.EMApiCondition) } Add-KabompoLogLine -Message "Finished adding condition ""$($Condition.EnConditionName)"" to action ""$($this.EnActionName)""" -Component "EMSequence.AddCondition" -Type 1 -LogLevel 2 -Verbose:$DoVerbose } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component EMSequence.Save -Type 3 -Verbose:$DoVerbose throw $_.Exception } } Add-Member -InputObject $o -MemberType ScriptMethod -Name "AddCondition" -Value $fAddCondition #endregion foreach($EMApiCondition in $EMApiAction.Conditions) { # Create EM-PS Object for the conditions $global:logIndention++ Add-KabompoLogLine -Message "Convert the condition to an PS Object" -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose $EMCondition = Convert-EMApiConditionToEMCondition -EMApiCondition $EMApiCondition $o.EMConditionList += ,$EMCondition $global:logIndention-- } # Format the object $VisibleProperties = @("EnActionName","DeActionName","ActionType","Icon","ActionOnErrorResumeNext","ConditionOnErrorResumeNext","SortKey","EMConditionList") Format-EMObject -VisibleProperties $VisibleProperties -EMObject $o -Verbose:$DoVerbose # Specify the type name $o.PSObject.TypeNames.Clear() $o.PSObject.TypeNames.Add("EMAction") $m = "Finished creating a new EM{0}Action" -f $ActionType Add-KabompoLogLine -Message $m -Component New-EMActionObject -Type 1 -LogLevel 0 -Verbose:$DoVerbose # return the object return $o } function New-EMApiAction { Param ( [Parameter(Mandatory=$true,Position=0)] [ValidateSet("Software","Restart","Service","Account","Registry","File","Folder","Process","Download","EnvironmentVar","Info","Monitoring","Application"<#,"PreDownload","Verify","UserProcess","GuiWindowSchedule","GuiWindowExecute","TaskStart","TaskFinish","None","TaskReminder",#>)] [string]$ActionType, [Parameter(Mandatory=$true,Position=1)] [string[]]$Parameter=$null, [Parameter(Mandatory=$true,Position=2)] [string]$DeDisplayName=$null, [Parameter(Mandatory=$true,Position=3)] [string]$EnDisplayName=$null, [Parameter(Mandatory=$true,Position=4)] [string]$DeDefaultDisplayName=$null, [Parameter(Mandatory=$true,Position=5)] [string]$EnDefaultDisplayName=$null, [Parameter(Mandatory=$true,Position=6)] [bool]$ActionOnErrorResumeNext=$False, [Parameter(Mandatory=$true,Position=7)] [bool]$ConditionOnErrorResumeNext=$False, [Parameter(Mandatory=$true,Position=8)] [int]$SortKey= 0 ) try { # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) Add-KabompoLogLine -Message "Start creating an EM-Api-Action" -Component New-EMApiAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Check if number of parameter is matching expectations if ($Parameter.Count -ne $global:ActionParameters[$ActionType].Count) { throw "Invalid parameter count for action of type ""$($ActionType)"". ""$($global:ActionParameters[$ActionType].Count)"" parameters expected, but just ""$($Parameter.Count)"" given." } Add-KabompoLogLine -Message "Create API Action and add properties..." -Component New-EMApiAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $EMApiAction= New-Object -TypeName Matrix42.EM.Contract.Container.v2.Sequence+Action $EMApiAction.De_DisplayName=$DeDisplayName $EMApiAction.En_DisplayName=$EnDisplayName $EMApiAction.De_DefaultDisplayName=$DeDefaultDisplayName $EMApiAction.En_DefaultDisplayName=$EnDefaultDisplayName $EMApiAction.Type= $ActionType $EMApiAction.Parameter.AddRange($Parameter) $EMApiAction.Icon=$ActionDefaultIcons[$ActionType] $EMApiAction.ActionOnErrorResumeNext= $ActionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext=$ConditionOnErrorResumeNext $EMApiAction.SortKey= $SortKey Add-KabompoLogLine -Message "Finished creating an EM-API-Action" -Component New-EMApiAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose return $EMApiAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component New-EMApiAction -Type 3 -Verbose:$DoVerbose throw $_.Exception } } function Convert-EMApiActionToEMAction { Param ( [Parameter(Mandatory=$true,Position=1)] $EMApiAction ) try { # should we do a verbose registration of logging module $DoVerbose = ($PSBoundParameters['Verbose'] -eq $true) $EMAction = $null Add-KabompoLogLine -Message "Start converting an API Action to an EM Action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose # Configure english text if(![string]::IsNullOrEmpty($EMApiAction.En_DisplayName)) { $EnDisplayName = $EMApiAction.En_DisplayName } else { $EnDisplayName = $EMApiAction.En_DefaultDisplayName } # Configure german text if(![string]::IsNullOrEmpty($EMApiAction.De_DisplayName)) { $DeDisplayName = $EMApiAction.De_DisplayName } else { $DeDisplayName = $EMApiAction.De_DefaultDisplayName } # Service Action if($EMApiAction.Type -eq "Service") { Add-KabompoLogLine -Message "Detected a service action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $ServiceName = $($EMApiAction.Parameter[0]) $ServiceActionType = $($EMApiAction.Parameter[1]) $EMAction = New-EMServiceAction -ServiceName $ServiceName -ServiceActionType $ServiceActionType -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose } # File Action elseif($EMApiAction.Type -eq "File") { Add-KabompoLogLine -Message "Detected a file action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $FileActionType = $($EMApiAction.Parameter[0]) $FilePath = $($EMApiAction.Parameter[1]) $Text = $($EMApiAction.Parameter[2]) $global:logIndention++ $EMAction = New-EMFileAction -FileActionType $FileActionType -FilePath $FilePath -Text $Text -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # Info Action elseif($EMApiAction.Type -eq "Info") { Add-KabompoLogLine -Message "Detected a info action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $HeadlineGerman = $($EMApiAction.Parameter[0]) $HeadlineEnglish = $($EMApiAction.Parameter[1]) $TextGerman = $($EMApiAction.Parameter[2]) $TextEnglish = $($EMApiAction.Parameter[3]) $Width = $($EMApiAction.Parameter[4]) $Height = $($EMApiAction.Parameter[5]) $AutoClose = $($EMApiAction.Parameter[6]) $Wait = $($EMApiAction.Parameter[7]) $Close = $($EMApiAction.Parameter[8]) $global:logIndention++ $EMAction = New-EMInfoAction -HeadlineGerman $HeadlineGerman -HeadlineEnglish $HeadlineEnglish -TextGerman TextGerman -TextEnglish $TextEnglish -Width $Width -Height $Height -AutoClose $AutoClose -Wait $Wait -Close $Close -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # Folder action elseif($EMApiAction.Type -eq "Folder") { Add-KabompoLogLine -Message "Detected a folder action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $FolderActionType = $($EMApiAction.Parameter[0]) $FolderPath = $($EMApiAction.Parameter[1]) $global:logIndention++ $EMAction = New-EMFolderAction -FolderActionType $FolderActionType -FolderPath $FolderPath -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # Process Action elseif($EMApiAction.Type -eq "Process") { Add-KabompoLogLine -Message "Detected a process action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $ProcessName = $($EMApiAction.Parameter[1]) $ProcessActionType = $($EMApiAction.Parameter[0]) $Arguments = $($EMApiAction.Parameter[2]) $Visibility = "Invisible" if($EMApiAction.Parameter[3] -eq "System") { $Visibility = "Invisible" } $Context = "System" # System Context if($EMApiAction.Parameter[4] -eq "User") { $Context = "User" } $WaitForEnd = $true # The action will wait, until the process is finished if($EMApiAction.Parameter[5] -eq "False") { $WaitForEnd = $false } $MaxRunTime = $($EMApiAction.Parameter[6]) $global:logIndention++ $EMAction = New-EMProcessAction -ProcessName $ProcessName -ProcessActionType $ProcessActionType -Arguments $Arguments -StartProcessVisible $Visibility -Context $Context -WaitForEnd $WaitForEnd -MaxRunTime $MaxRunTime -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # Restart Action elseif($EMApiAction.Type -eq "Restart") { Add-KabompoLogLine -Message "Detected a restart action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $RestartActionType = $($EMApiAction.Parameter[0]) $KillApplications = $($EMApiAction.Parameter[1]) $UserCanMoveTime = $($EMApiAction.Parameter[2]) $AutoRestart = $($EMApiAction.Parameter[3]) $DeMessage = $($EMApiAction.Parameter[4]) $EnMessage = $($EMApiAction.Parameter[5]) $global:logIndention++ $EMAction = New-EMRestartAction -RestartActionType $RestartActionType -KillApplications $KillApplications -UserCanMoveTime $UserCanMoveTime -AutoRestart $AutoRestart -DeMessage $DeMessage -EnMessage $EnMessage -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # Monitoring Action elseif($EMApiAction.Type -eq "Monitoring") { Add-KabompoLogLine -Message "Detected a monitoring action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $AutoClose = $($EMApiAction.Parameter[0]) $Processes = @() for($i=0; $i -lt $EMApiAction.Parameter.Count; $i++) { # Skip first value if($i -eq 0) { continue } $Processes += ,$EMApiAction.Parameter[$i] } $global:logIndention++ $EMAction = New-EMMonitoringAction -AutoClose $AutoClose -Processes $Processes -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # Registry Action elseif($EMApiAction.Type -eq "Registry") { Add-KabompoLogLine -Message "Detected a registry action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $RegistryActionType = $($EMApiAction.Parameter[0]) $RegistryKey = $($EMApiAction.Parameter[1]) $ValueName = $($EMApiAction.Parameter[2]) $ValueType = $($EMApiAction.Parameter[3]) $Value = $($EMApiAction.Parameter[4]) $global:logIndention++ $EMAction = New-EMRegistryAction -RegistryActionType $RegistryActionType -RegistryKey $RegistryKey -ValueName $ValueName -ValueType $ValueType -Value $Value -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # Account Action elseif($EMApiAction.Type -eq "Account") { Add-KabompoLogLine -Message "Detected an account action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $Account = $($EMApiAction.Parameter[0]) $AccountType = $($EMApiAction.Parameter[1]) # Group / Account $LocalOrGlobalAccount = $($EMApiAction.Parameter[2]) # Local / Global $LocalTargetObject = $($EMApiAction.Parameter[3]) $AdTargetObject = $($EMApiAction.Parameter[4]) $TargetObjectType = $($EMApiAction.Parameter[5]) # Account / Group $AdAccessObject = $($EMApiAction.Parameter[6]) # The account to access the AD $AdAccessObjectType = $($EMApiAction.Parameter[7]) # Account / Group $AdAccessAcountPwdEncrypted = $($EMApiAction.Parameter[8]) # The password to access the AD (encrypted) $AccountActionType = $($EMApiAction.Parameter[9]) # Add / Remove $global:logIndention++ $EMAction = New-EMAccountAction -Account $Account -AccountType $AccountType -LocalOrGlobalAccount $LocalOrGlobalAccount -LocalTargetObject $LocalTargetObject -AdTargetObject $AdTargetObject -TargetObjectType $TargetObjectType -AdAccessObject $AdAccessObject -AdAccessObjectType $AdAccessObjectType -AdAccessObjectPwdEncrypted $AdAccessAcountPwdEncrypted -AccountActionType $AccountActionType -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # SCCM Application Action elseif($EMApiAction.Type -eq "Application") { Add-KabompoLogLine -Message "Detected an SCCM Application action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $SccmApplicationId = $($EMApiAction.Parameter[0]) # ScopeId and "Application" (which is the deployment type) $SccmApplicationActionType = $($EMApiAction.Parameter[1]) # Install / Uninstall $SccmApplicationParam = $($EMApiAction.Parameter[2]) # Parameterlist of commandline $global:logIndention++ $EMAction = New-EMSccmApplicationAction -SccmApplicationId $SccmApplicationId -SccmApplicationActionType $SccmApplicationActionType -SccmApplicationParam $SccmApplicationParam -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # SCCM Package Action elseif($EMApiAction.Type -eq "Software") { Add-KabompoLogLine -Message "Detected an SCCM Package action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $SccmPackageId = $($EMApiAction.Parameter[0]) $SccmPackageProgram = $($EMApiAction.Parameter[1]) $SccmPackageParam = $($EMApiAction.Parameter[2]) # Parameterlist of commandline $SccmPackageActionType = $($EMApiAction.Parameter[3]) # Install / Uninstall $global:logIndention++ $EMAction = New-EMSccmPackageAction -SccmPackageId $SccmPackageId -SccmPackageProgram $SccmPackageProgram -SccmPackageParam $SccmPackageParam -SccmPackageActionType $SccmPackageActionType -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # SCCM Download Action elseif($EMApiAction.Type -eq "Download") { Add-KabompoLogLine -Message "Detected an SCCM Download action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $SccmPackageId = $($EMApiAction.Parameter[0]) $DownloadFolder = $($EMApiAction.Parameter[1]) $SccmPackageName = $($EMApiAction.Parameter[2]) $global:logIndention++ $EMAction = New-EMSccmDownloadAction -SccmPackageId $SccmPackageId -DownloadFolder $DownloadFolder -SccmPackageName $SccmPackageName -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } # EnvironmentVar(iable) Action elseif($EMApiAction.Type -eq "EnvironmentVar") { Add-KabompoLogLine -Message "Detected an Environment Variable action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose $VariableName = $($EMApiAction.Parameter[0]) $VariableActionType = $($EMApiAction.Parameter[1]) $VariableScope = $($EMApiAction.Parameter[2]) $VariableValueType = $($EMApiAction.Parameter[3]) $VariableValue = $($EMApiAction.Parameter[4]) $global:logIndention++ $EMAction = New-EMVariableAction -VariableActionType $VariableActionType -VariableName $VariableName -VariableValueType $VariableValueType -VariableScope $VariableScope -VariableValue $VariableValue -ActionOnErrorResumeNext $EMApiAction.ActionOnErrorResumeNext -ConditionOnErrorResumeNext $EMApiAction.ConditionOnErrorResumeNext -SortKey $EMApiAction.Sortkey -DeDisplayName $DeDisplayName -EnDisplayName $EnDisplayName -EMApiAction $EMApiAction -Verbose:$DoVerbose $global:logIndention-- } else { throw "Actiontype ""$($EMApiAction.Type)"" currently not supported" } Add-KabompoLogLine -Message "Finished converting an API Action to an EM Action" -Component Convert-EMApiActionToEMAction -Type 1 -LogLevel 0 -Verbose:$DoVerbose return $EMAction } catch { Add-KabompoLogLine -Message "Something went wrong" -ErrorMessage $_.Exception.Message -Component Convert-EMApiActionToEMAction -Type 3 -LogLevel 0 -Verbose:$DoVerbose $EMAction=$null throw $_.Exception } } # SIG # Begin signature block # MIINJAYJKoZIhvcNAQcCoIINFTCCDRECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUhacrfIY/Kd5OEbPUvzSVPfFG # mOGgggpZMIIE+DCCA+CgAwIBAgIQXWihGXfS4Od7/8YeI88pIDANBgkqhkiG9w0B # AQsFADB/MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRp # b24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxMDAuBgNVBAMTJ1N5 # bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUgU2lnbmluZyBDQTAeFw0xNTAyMDMw # MDAwMDBaFw0xODA0MDMyMzU5NTlaMGAxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIEwZI # ZXNzZW4xEjAQBgNVBAcTCUZyYW5rZnVydDEVMBMGA1UEChQMTWF0cml4IDQyIEFH # MRUwEwYDVQQDFAxNYXRyaXggNDIgQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw # ggEKAoIBAQDHZNuFnBatHdyRnMUJ2Y1P6k49MjD04t9S7ukWj8upP/B6wPRYzzQf # 6QVMPKzMhNTPfIXaIEzi/jhT0jjwnX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R3b3JrMTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1NiBD # b2RlIFNpZ25pbmcgQ0ECEF1ooRl30uDne//GHiPPKSAwCQYFKw4DAhoFAKB4MBgG # CisGAQQBgjcCAQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcC # AQQwHAYKKwYBBAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYE # FF8CRYNoa/61u5kctTYlFx4ujfWbMA0GCSqGSIb3DQEBAQUABIIBAJV2/+DUrbnt # X3WaHnWfe+2pXgBNcMN2Vjznt5jLgbXoX9C7XWg06uERhGHKpGOXCJkZAsUSF3tX # hcw5p7BhZrXGGvp7AAl/Q+hi24cLKKL7Vh7Fi98E7C5LJkxhdaP6lG7TfudoB4ZJ # hPax5wMqFtlVONH5pRP0QuPM8iBDh+nZn7eCNwBetk7GGICWSsiXQjdty4ws4MNj # hpa5oqOEN337vQsv3FwuF0PhhlrTHQhIT9ivstTNeXjG7iyykYHVZ5EuZe6ysTFl # 37D4++g6YrJdaiqPcg3uRLK33ZrINdyb+pIh+TINpz1Lvap6X2ePqkCmyO9mzyb7 # DKGmN9LNRt0= # SIG # End signature block
PowerShellCorpus/PowerShellGallery/AutomatedLab/3.9.0.6/AutomatedLab.init.ps1
AutomatedLab.init.ps1
Add-Type -Path $PSScriptRoot\AutomatedLab.dll
PowerShellCorpus/PowerShellGallery/biz.dfch.PS.Appclusive.Client/5.2.1.20161201/Format-Exception.ps1
Format-Exception.ps1
function Format-Exception { <# .SYNOPSIS Displays details of an exception. .DESCRIPTION Displays details of an exception. For a given exception that occurred during execution of an Appclusive API call this Cmdlet will show you the details of. .INPUTS The Cmdlet can either return all available versions or version per single item. See PARAMETERS section on possible inputs. .OUTPUTS default | json | json-pretty | xml | xml-pretty .EXAMPLE # Extracts the innermost exception from a failed SaveChanges operation. PS > $node = New-Object biz.dfch.CS.Appclusive.Api.Core.Node; PS > $svc.Core.AddToNodes($node); PS > $svc.Core.SaveChanges(); PS > Format-Exception System.Data.Services.Client.DataServiceClientException: HTTP 400. entity : A null value was found for the property named 'Name', which has the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values. .EXAMPLE # Extracts the HTTP StatusCode from the innermost exception if there is a StatusCode. PS > $node = New-Object biz.dfch.CS.Appclusive.Api.Core.Node; PS > $svc.Core.AddToNodes($node); PS > $svc.Core.SaveChanges(); PS > Format-Exception -StatusCode 400 .EXAMPLE # Extracts all exceptions from a failed SaveChanges operation. PS > $node = New-Object biz.dfch.CS.Appclusive.Api.Core.Node; PS > $svc.Core.AddToNodes($node); PS > $svc.Core.SaveChanges(); PS > Format-Exception -ListAvailable System.Management.Automation.MethodInvocationException System.Data.Services.Client.DataServiceRequestException System.Data.Services.Client.DataServiceClientException .EXAMPLE # Extracts all exceptions details from a failed SaveChanges operation. PS > $node = New-Object biz.dfch.CS.Appclusive.Api.Core.Node; PS > $svc.Core.AddToNodes($node); PS > $svc.Core.SaveChanges(); PS > Format-Exception -All Exception calling "SaveChanges" with "0" argument(s): "An error occurred while processing this request." Response : {System.Data.Services.Client.ChangeOperationResponse} Message : An error occurred while processing this request. Data : {} InnerException : System.Data.Services.Client.DataServiceClientException: { "odata.error":{ "code":"","message":{ "lang":"en-US","value":"The request is invalid." },"innererror":{ "message":"entity : A null value was found for the property named 'Name', which has the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values.\r\n","type":"","stacktrace":"" } } } TargetSite : System.Data.Services.Client.DataServiceResponse HandleResponse() StackTrace : at System.Data.Services.Client.SaveResult.HandleResponse() at System.Data.Services.Client.BaseSaveResult.EndRequest() at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options) at CallSite.Target(Closure , CallSite , Object ) HelpLink : Source : Microsoft.Data.Services.Client HResult : -2146233079 StatusCode : 400 Message : { "odata.error":{ "code":"","message":{ "lang":"en-US","value":"The request is invalid." },"innererror":{ "message":"entity : A null value was found for the property named 'Name', which has the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values.\r\n","type":"","stacktrace":"" } } } Data : {} InnerException : TargetSite : StackTrace : HelpLink : Source : HResult : -2146233079 .LINK Online Version: http://dfch.biz/biz/dfch/PS/Appclusive/Client/Format-Exception/ .NOTES See module manifest for required software versions and dependencies. #> [CmdletBinding( SupportsShouldProcess = $false , ConfirmImpact = 'Low' , HelpURI = 'http://dfch.biz/biz/dfch/PS/Appclusive/Client/Format-Exception/' , DefaultParameterSetName = 'single' )] PARAM ( # Specifies the ErrorRecord to analyse [Parameter(Mandatory = $false, Position = 0)] [ValidateNotNullOrEmpty()] [Alias('er')] [System.Management.Automation.ErrorRecord] $ErrorRecord = $Global:Error[0] , # Specifies the (partial) exception type to analyse [Parameter(Mandatory = $false, ParameterSetName = 'single')] [string] $Name , # Extracts the HTTP StatusCode from the exception chain if available [Parameter(Mandatory = $false, ParameterSetName = 'single')] [Switch] $StatusCode = $false , # Displays all exceptions within ErrorRecord [Parameter(Mandatory = $false, ParameterSetName = 'all')] [Switch] $All , # Lists the names of all exceptions within the ErrorRecord [Parameter(Mandatory = $false, ParameterSetName = 'list')] [Alias('list')] [Switch] $ListAvailable , # Specifies the return format of the Cmdlet [ValidateSet('default', 'json', 'json-pretty', 'xml', 'xml-pretty')] [Parameter(Mandatory = $false)] [alias('ReturnFormat')] [string] $As = 'default' ) Begin { trap { Log-Exception $_; break; } $datBegin = [datetime]::Now; [string] $fn = $MyInvocation.MyCommand.Name; } # Begin Process { trap { Log-Exception $_; break; } # Default test variable for checking function response codes. [Boolean] $fReturn = $false; switch($PSCmdlet.ParameterSetName) { 'list' { $Response = @(); $ex = $ErrorRecord.Exception; while($ex) { $Response += $ex.GetType().FullName; $ex = $ex.InnerException; } } 'all' { $Response = @(); $ex = $ErrorRecord.Exception; while($ex) { $Response += $ex; $ex = $ex.InnerException.PSBase; } } 'single' { $ex = $ErrorRecord.Exception; $result = Find-Exception $ex $Name; if(!$result) { $Response = $null; } elseif($result -is [System.Data.Services.Client.DataServiceClientException]) { if($StatusCode) { $Response = $ex.StatusCode; } else { $Response = Format-DataServiceClientException $result; } } else { $Response = ("{0}: {1}" -f $result.GetType().FullName, ($result.PSBase | Out-String)); } } default { $er = New-CustomErrorRecord -cat InvalidArgument -o $PSCmdlet.ParameterSetName ("Invalid ParameterSetName '{0}'" -f $PSCmdlet.ParameterSetName); $PSCmdlet.ThrowTerminatingError($er); } } $OutputParameter = Format-ResultAs $Response $As $fReturn = $true; } # Process End { $datEnd = [datetime]::Now; Log-Debug -fn $fn -msg ("RET. fReturn: [{0}]. Execution time: [{1}]ms. Started: [{2}]." -f $fReturn, ($datEnd - $datBegin).TotalMilliseconds, $datBegin.ToString('yyyy-MM-dd HH:mm:ss.fffzzz')) -fac 2; # Return values are always and only returned via OutputParameter. return $OutputParameter; } # End } # function function Find-Exception($ex, $name) { Contract-Requires (!!$ex); Contract-Requires ($ex -is [Exception]); $parentEx = $ex; $isExceptionFound = $false; while($ex) { if($name -and ($ex.GetType().FullName -match $name)) { $isExceptionFound = $true; break; } $parentEx = $ex; $ex = $ex.InnerException; } if(!$isExceptionFound) { if($name) { $ex = $null; } else { $ex = $parentEx; } } return $ex; } function Format-DataServiceClientException($ex) { Contract-Requires ($ex -is [System.Data.Services.Client.DataServiceClientException]) try { [xml] $xml = $ex.Message; $message = $xml.head.title; } catch { try { $dic = New-Object biz.dfch.CS.Appclusive.Public.DictionaryParameters($er.Exception.InnerException.InnerException.Message); if(0 -ge $dic.Keys.Count) { $message = $ex.Message; } else { $message = $dic.GetOrSelf('odata.error').GetOrSelf('message').GetOrSelf('value'); if($message -eq $dic) { $message = $dic.ToString(); } } } catch { $message = $ex.Message } } $result = "{0}: HTTP {1}.`r`n{2}`r`n{3}" -f $ex.GetType().FullName, $ex.StatusCode, $message, $ex.StackTrace; return $result; } if($MyInvocation.ScriptName) { Export-ModuleMember -Function Format-Exception; } # # Copyright 2015-2016 d-fens GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # SIG # Begin signature block # MIIXDwYJKoZIhvcNAQcCoIIXADCCFvwCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU9S13Mf2i+V8n7dM0RUy1VGKk # caCgghHCMIIEFDCCAvygAwIBAgILBAAAAAABL07hUtcwDQYJKoZIhvcNAQEFBQAw # VzELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNV # BAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw0xMTA0 # MTMxMDAwMDBaFw0yODAxMjgxMjAwMDBaMFIxCzAJBgNVBAYTAkJFMRkwFwYDVQQK # ExBHbG9iYWxTaWduIG52LXNhMSgwJgYDVQQDEx9HbG9iYWxTaWduIFRpbWVzdGFt # cGluZyBDQSAtIEcyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlO9l # +LVXn6BTDTQG6wkft0cYasvwW+T/J6U00feJGr+esc0SQW5m1IGghYtkWkYvmaCN # d7HivFzdItdqZ9C76Mp03otPDbBS5ZBb60cO8eefnAuQZT4XljBFcm05oRc2yrmg # jBtPCBn2gTGtYRakYua0QJ7D/PuV9vu1LpWBmODvxevYAll4d/eq41JrUJEpxfz3 # zZNl0mBhIvIG+zLdFlH6Dv2KMPAXCae78wSuq5DnbN96qfTvxGInX2+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pZ24gbnYtc2ExKDAmBgNVBAMTH0dsb2JhbFNpZ24gVGlt # ZXN0YW1waW5nIENBIC0gRzICEhEh1pmnZJc+8fhCfukZzFNBFDAJBgUrDgMCGgUA # oIH9MBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE2 # MDgzMTE5MTYzOFowIwYJKoZIhvcNAQkEMRYEFGTiT8ApwRMFPduo7TU3FuERA+ZU # MIGdBgsqhkiG9w0BCRACDDGBjTCBijCBhzCBhAQUY7gvq2H1g5CWlQULACScUCkz # 7HkwbDBWpFQwUjELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYt # c2ExKDAmBgNVBAMTH0dsb2JhbFNpZ24gVGltZXN0YW1waW5nIENBIC0gRzICEhEh # 1pmnZJc+8fhCfukZzFNBFDANBgkqhkiG9w0BAQEFAASCAQCso0iyq9AOtPiKjK0Y # 4hjD1DJNLjbAEJaq0AHICiWJNTP34no9ZTTz3Fj4qap/1CMCt4xp5CQJn3STbmIh # VnuVFyqgQ8lsMLrN6destBw6treRWGjzDg/tIeG+a0wu214MtY5RPaEWmZW/XCXz # srV83b+OrTFs5A7ids6KR0u7wqK7q6fMJPoNdRRINISDw/vtSuNW1h0m9lloNqIb # dueyXLl/B/dHsczn8JAbTGfFIIIfvACqXiW9ew+qVM9GeT2Ps/zEILY0vulpxmaO # fgE4YbADCRyQ2KV7st7A7AkvOgdTgbYFB8VuLdCK5mTxmBE2jkerquZQNc49m35m # 0yfd # SIG # End signature block
PowerShellCorpus/PowerShellGallery/biz.dfch.PS.Appclusive.Client/5.2.1.20161201/Get-Time.ps1
Get-Time.ps1
function Get-Time { <# .SYNOPSIS Get the actual time of the Appclusive server. .DESCRIPTION Get the actual time of the Appclusive server. .INPUTS See PARAMETERS section for possible inputs. .OUTPUTS default | json | json-pretty | xml | xml-pretty | DateTimeOffset .EXAMPLE # In this example we query the current time of the Appclusive server PS > Get-Time 2016-09-14T15:34:29.951+02:00 .LINK Online Version: http://dfch.biz/biz/dfch/PS/Appclusive/Client/Get-Time/ .NOTES See module manifest for required software versions and dependencies. #> [CmdletBinding( SupportsShouldProcess = $false , ConfirmImpact = 'Low' , HelpURI = 'http://dfch.biz/biz/dfch/PS/Appclusive/Client/Get-Time/' )] PARAM ( # Service reference to Appclusive [Parameter(Mandatory = $false)] [Alias('Services')] [hashtable] $svc = (Get-Variable -Name $MyInvocation.MyCommand.Module.PrivateData.MODULEVAR -ValueOnly).Services , # Specifies the return format of the Cmdlet [ValidateSet('default', 'json', 'json-pretty', 'xml', 'xml-pretty', 'DateTimeOffset')] [Parameter(Mandatory = $false)] [alias('ReturnFormat')] [string] $As = 'default' ) Begin { trap { Log-Exception $_; break; } $datBegin = [datetime]::Now; [string] $fn = $MyInvocation.MyCommand.Name; Log-Debug -fn $fn -msg ("CALL. svc '{0}'. Name '{1}'." -f ($svc -is [Object]), $Name) -fac 1; $EntitySetName = 'Endpoints'; # Parameter validation Contract-Requires ($svc.Core -is [biz.dfch.CS.Appclusive.Api.Core.Core]) "Connect to the server before using the Cmdlet" } # Begin Process { trap { Log-Exception $_; break; } # Default test variable for checking function response codes. [Boolean] $fReturn = $false; # Return values are always and only returned via OutputParameter. $OutputParameter = $null; # Parameter validation # N/A $Response = $svc.Diagnostics.InvokeEntitySetActionWithSingleResult($EntitySetName, 'Time', [string], $null); if($As -eq 'DateTimeOffset') { $OutputParameter = [System.DateTimeOffset]::Parse($Response); } else { $OutputParameter = Format-ResultAs $Response $As } $fReturn = $true; } # Process End { $datEnd = [datetime]::Now; Log-Debug -fn $fn -msg ("RET. fReturn: [{0}]. Execution time: [{1}]ms. Started: [{2}]." -f $fReturn, ($datEnd - $datBegin).TotalMilliseconds, $datBegin.ToString('yyyy-MM-dd HH:mm:ss.fffzzz')) -fac 2; # Return values are always and only returned via OutputParameter. return $OutputParameter; } # End } # function if($MyInvocation.ScriptName) { Export-ModuleMember -Function Get-Time; } # # Copyright 2014-2015 d-fens GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # SIG # Begin signature block # MIIXDwYJKoZIhvcNAQcCoIIXADCCFvwCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUBCiisVz2YEkvP9UVUlfK8Ykh # hfugghHCMIIEFDCCAvygAwIBAgILBAAAAAABL07hUtcwDQYJKoZIhvcNAQEFBQAw # VzELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNV # BAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw0xMTA0 # MTMxMDAwMDBaFw0yODAxMjgxMjAwMDBaMFIxCzAJBgNVBAYTAkJFMRkwFwYDVQQK # ExBHbG9iYWxTaWduIG52LXNhMSgwJgYDVQQDEx9HbG9iYWxTaWduIFRpbWVzdGFt # cGluZyBDQSAtIEcyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlO9l # +LVXn6BTDTQG6wkft0cYasvwW+T/J6U00feJGr+esc0SQW5m1IGghYtkWkYvmaCN # d7HivFzdItdqZ9C76Mp03otPDbBS5ZBb60cO8eefnAuQZT4XljBFcm05oRc2yrmg # jBtPCBn2gTGtYRakYua0QJ7D/PuV9vu1LpWBmODvxevYAll4d/eq41JrUJEpxfz3 # zZNl0mBhIvIG+zLdFlH6Dv2KMPAXCae78wSuq5DnbN96qfTvxGInX2+ZbTh0qhGL # 2t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BgNVBAMTH0dsb2JhbFNpZ24gVGlt # ZXN0YW1waW5nIENBIC0gRzICEhEh1pmnZJc+8fhCfukZzFNBFDAJBgUrDgMCGgUA # oIH9MBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE2 # MDgzMTE5MTY0OFowIwYJKoZIhvcNAQkEMRYEFOyjwsjFg4+1ewAu9diq1O01TKe7 # MIGdBgsqhkiG9w0BCRACDDGBjTCBijCBhzCBhAQUY7gvq2H1g5CWlQULACScUCkz # 7HkwbDBWpFQwUjELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYt # c2ExKDAmBgNVBAMTH0dsb2JhbFNpZ24gVGltZXN0YW1waW5nIENBIC0gRzICEhEh # 1pmnZJc+8fhCfukZzFNBFDANBgkqhkiG9w0BAQEFAASCAQCIEB7/pqGFn4EKRkFm # GT9u7GX01GqeNpy+s7gkz9A8ihFk8vHiK3/yAdGa2/Qq52MuKxRsDfTLy7WrIzUJ # yn89wpNEFWIGv3kmX9EgFeDHqRIdfyC9fLyEtV7sHBI6Y1i3DW8gpDx9e/4nFV5x # TX+y3zQNvsd4Eqi1Mi0gzlXg1FjTkL8vOcOFXxxCNJhUiotGcoQ8lJj93YO8pHeh # L8xibE/LIeZDF3Cg8fS7BdR14Z1T0eA6zccDAz+k45fSr3BczA13Q63bYm8i68K1 # kJlgI+/cpJrFJ6ZbhyQSMW/l3bxWY822BLcS3YrYkqO8EiHRb9FognGda7yMITHx # sgMh # SIG # End signature block
PowerShellCorpus/PowerShellGallery/biz.dfch.PS.Appclusive.Client/5.2.1.20161201/Set-ManagementUri.ps1
Set-ManagementUri.ps1
function Set-ManagementUri { <# .SYNOPSIS Sets or creates a ManagementUri entry in Appclusive. .DESCRIPTION Sets or creates a ManagementUri entry in Appclusive. By updating a ManagementUri entry you can specify if you want to update the name, type or description or any combination thereof. For a new name or type you need to use the Argument '-NewName' or '-NewType' .OUTPUTS default .EXAMPLE Set-ManagementUri -Name "MyName" -Type "MyType" -svc $svc -CreateIfNotExist Type : MyType Value : ManagementCredentialId : Id : 180 Tid : 11111111-1111-1111-1111-111111111111 Name : MyName Description : CreatedById : 1 ModifiedById : 1 Created : 22.08.2016 10:26:53 +02:00 Modified : 22.08.2016 10:31:00 +02:00 RowVersion : {0, 0, 0, 0...} ManagementCredential : Tenant : CreatedBy : ModifiedBy : Create a new ManagementUri entry if it does not exists. .EXAMPLE Set-ManagementUri -Name "MyName" -Type "MyType" -NewName "MyNewName" -NewType "MyNewType" -Description "MyNewDescription" -svc $svc Type : MyNewType Value : ManagementCredentialId : Id : 180 Tid : 11111111-1111-1111-1111-111111111111 Name : MyNewName Description : MyNewDescription CreatedById : 1 ModifiedById : 1 Created : 22.08.2016 10:26:53 +02:00 Modified : 22.08.2016 10:31:00 +02:00 RowVersion : {0, 0, 0, 0...} ManagementCredential : Tenant : CreatedBy : ModifiedBy : Update an existing ManagementUri with new name, description and type. .LINK Online Version: http://dfch.biz/biz/dfch/PS/Appclusive/Client/Set-ManagementUri/ Set-ManagementUri: http://dfch.biz/biz/dfch/PS/Appclusive/Client/Set-ManagementUri/ .NOTES See module manifest for dependencies and further requirements. #> [CmdletBinding( SupportsShouldProcess = $false , ConfirmImpact = 'Low' , HelpURI = 'http://dfch.biz/biz/dfch/PS/Appclusive/Client/Set-ManagementUri/' )] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")] Param ( # Specifies the name to modify [Parameter(Mandatory = $true, Position = 0)] [ValidateNotNullOrEmpty()] [Alias('n')] [string] $Name , # Specifies the type to modify [Parameter(Mandatory = $true, Position = 1)] [ValidateNotNullOrEmpty()] [string] $Type , # Specifies the value [Parameter(Mandatory = $false, Position = 2)] [ValidateNotNullOrEmpty()] [string] $Value , # Specifies the new name [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [string] $NewName , # Specifies the new name [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [string] $NewType , # Specifies the description [Parameter(Mandatory = $false)] [Alias("d")] [string] $Description , # Specifies the ManagementCredentialId [Parameter(Mandatory = $false)] [ValidateRange(1,[long]::MaxValue)] [long] $ManagementCredentialId , # Specifies to create a entity if it does not exist [Parameter(Mandatory = $false)] [Alias("c")] [switch] $CreateIfNotExist = $false , # Service reference to Appclusive [Parameter(Mandatory = $false)] [Alias('Services')] [hashtable] $svc = (Get-Variable -Name $MyInvocation.MyCommand.Module.PrivateData.MODULEVAR -ValueOnly).Services , # Specifies the return format of the Cmdlet [ValidateSet('default', 'json', 'json-pretty', 'xml', 'xml-pretty')] [Parameter(Mandatory = $false)] [alias('ReturnFormat')] [string] $As = 'default' ) Begin { trap { Log-Exception $_; break; } $datBegin = [datetime]::Now; [string] $fn = $MyInvocation.MyCommand.Name; Log-Debug -fn $fn -msg ("CALL. svc '{0}'. Name '{1}'." -f ($svc -is [Object]), $Name) -fac 1; # Parameter validation Contract-Requires ($svc.Core -is [biz.dfch.CS.Appclusive.Api.Core.Core]) "Connect to the server before using the Cmdlet" if ($ManagementCredentialId) { $mgmtCred = Get-ManagementCredential -Id $ManagementCredentialId -svc $svc; Contract-Assert (!!$mgmtCred) "MgmtCredential with Id = $ManagementCredentialId does not exist"; } } # Begin Process { # Default test variable for checking function response codes. [Boolean] $fReturn = $false; # Return values are always and only returned via OutputParameter. $OutputParameter = $null; $AddedEntity = $null; try { $exp = @(); $exp += ("(tolower(Type) eq '{0}')" -f $Type.ToLower()); $exp += ("(tolower(Name) eq '{0}')" -f $Name.ToLower()); $FilterExpression = [String]::Join(' and ', $exp); $entity = $svc.Core.ManagementUris.AddQueryOption('$filter', $FilterExpression).AddQueryOption('$top',1) | Select; if(!$CreateIfNotExist -And !$entity) { $msg = "Name: Parameter validation FAILED. Entity does not exist. Use '-CreateIfNotExist' to create resource: '{0}'" -f $Name; $e = New-CustomErrorRecord -m $msg -cat ObjectNotFound -o $Name; throw($gotoError); } if(!$entity) { $entity = New-Object biz.dfch.CS.Appclusive.Api.Core.ManagementUri; $svc.Core.AddToManagementUris($entity); $AddedEntity = $entity; $entity.Name = $Name; $entity.Type = $Type; $entity.Created = [System.DateTimeOffset]::Now; $entity.Modified = $entity.Created; $entity.CreatedById = 0; $entity.ModifiedById = 0; $entity.Tid = [guid]::Empty.ToString(); } if($PSBoundParameters.ContainsKey('Description')) { $entity.Description = $Description; } if($PSBoundParameters.ContainsKey('ManagementCredentialId')) { $entity.ManagementCredentialId = $ManagementCredentialId; } if($PSBoundParameters.ContainsKey('Value')) { $entity.Value = $Value; } if($NewName) { $entity.Name = $NewName; } if($NewType) { $entity.Type = $NewType; } $svc.Core.UpdateObject($entity); $r = $svc.Core.SaveChanges(); $r = $entity; $OutputParameter = Format-ResultAs $r $As; $fReturn = $true; } catch { if($gotoSuccess -eq $_.Exception.Message) { $fReturn = $true; } else { [string] $ErrorText = "catch [$($_.FullyQualifiedErrorId)]"; $ErrorText += (($_ | fl * -Force) | Out-String); $ErrorText += (($_.Exception | fl * -Force) | Out-String); $ErrorText += (Get-PSCallStack | Out-String); if($_.Exception -is [System.Net.WebException]) { Log-Critical $fn ("[WebException] Request FAILED with Status '{0}'. [{1}]." -f $_.Exception.Status, $_); Log-Debug $fn $ErrorText -fac 3; } else { Log-Error $fn $ErrorText -fac 3; if($gotoError -eq $_.Exception.Message) { Log-Error $fn $e.Exception.Message; $PSCmdlet.ThrowTerminatingError($e); } elseif($gotoFailure -ne $_.Exception.Message) { Write-Verbose ("$fn`n$ErrorText"); } else { # N/A } } $fReturn = $false; $OutputParameter = $null; if($AddedEntity) { $svc.Core.DeleteObject($AddedEntity); } } } finally { # Clean up # N/A } } # Process End { $datEnd = [datetime]::Now; Log-Debug -fn $fn -msg ("RET. fReturn: [{0}]. Execution time: [{1}]ms. Started: [{2}]." -f $fReturn, ($datEnd - $datBegin).TotalMilliseconds, $datBegin.ToString('yyyy-MM-dd HH:mm:ss.fffzzz')) -fac 2; # Return values are always and only returned via OutputParameter. return $OutputParameter; } # End } if($MyInvocation.ScriptName) { Export-ModuleMember -Function Set-ManagementUri; } # # Copyright 2014-2015 d-fens GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # SIG # Begin signature block # MIIXDwYJKoZIhvcNAQcCoIIXADCCFvwCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUjMX3p0A1QFAxTb4AjmtghUOY # eJigghHCMIIEFDCCAvygAwIBAgILBAAAAAABL07hUtcwDQYJKoZIhvcNAQEFBQAw # VzELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNV # BAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw0xMTA0 # MTMxMDAwMDBaFw0yODAxMjgxMjAwMDBaMFIxCzAJBgNVBAYTAkJFMRkwFwYDVQQK # ExBHbG9iYWxTaWduIG52LXNhMSgwJgYDVQQDEx9HbG9iYWxTaWduIFRpbWVzdGFt # cGluZyBDQSAtIEcyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlO9l # +LVXn6BTDTQG6wkft0cYasvwW+T/J6U00feJGr+esc0SQW5m1IGghYtkWkYvmaCN # d7HivFzdItdqZ9C76Mp03otPDbBS5ZBb60cO8eefnAuQZT4XljBFcm05oRc2yrmg # jBtPCBn2gTGtYRakYua0QJ7D/PuV9vu1LpWBmODvxevYAll4d/eq41JrUJEpxfz3 # zZNl0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