Public/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 } } |