48 lines
1.8 KiB
PowerShell
48 lines
1.8 KiB
PowerShell
|
function Get-PlatformElementInventory {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Get all PlatformElementDetail data in json from a BoRG Uri based on the EnvironmentName
|
||
|
|
||
|
.EXAMPLE
|
||
|
Get-PlatformElementInventory -BorgUri "http://uri.to.borg.com" -EnvironmentName "AWS Sandbox Box 0.2 MIC"
|
||
|
|
||
|
.PARAMETER BorgUri
|
||
|
The Uri to the BoRG REST endpoint
|
||
|
|
||
|
.PARAMETER EnvironmentName
|
||
|
Filters based on the provided Environment Name. If not provided, the local machine.config Environment.Name appSetting value will be used.
|
||
|
#>
|
||
|
|
||
|
[CmdletBinding()]
|
||
|
Param(
|
||
|
[Parameter(Mandatory = $true)]
|
||
|
[string]$BorgUri,
|
||
|
|
||
|
[Parameter(Mandatory = $false)]
|
||
|
[string]$EnvironmentName
|
||
|
)
|
||
|
|
||
|
$packages = New-Object System.Collections.ArrayList
|
||
|
|
||
|
#Get environment name locally if not provided
|
||
|
if ([String]::IsNullOrEmpty($environmentName)) {
|
||
|
$environmentName = Get-AppSetting -appSettingKey "Environment.Name"
|
||
|
}
|
||
|
|
||
|
$Uri = "$BorgUri/odata/PlatformElementDetails?`$filter=IsCurrent eq true and EnvironmentType/Name eq '$environmentName'&`$expand=Element(`$select=Name;`$expand=ElementTier(`$select=Name)),ElementVersion(`$select=Name)&`$select=Element,ElementVersion"
|
||
|
|
||
|
$platformElementInventory = Invoke-RestMethod -Uri $Uri -Method GET -ContentType "application/json"
|
||
|
|
||
|
if ($platformElementInventory.value.Length -gt 0) {
|
||
|
foreach ($item in $platformElementInventory.value) {
|
||
|
$name = $item.Element.Name
|
||
|
$version = $item.ElementVersion.Name
|
||
|
$tier = $item.Element.ElementTier.Name
|
||
|
$properties = @{ Name = $name; Version = $version; Tier = $tier; Feed = $null; Tags = $null; IsService = $null; StartMode = $null }
|
||
|
$pkg = New-Object -TypeName PSObject -Prop $properties
|
||
|
($packages.Add($pkg)) | Out-Null
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return $packages
|
||
|
}
|