Public/Tools/Get-ConfigurationItemProperty.ps1
function Get-ConfigurationItemProperty { <# .SYNOPSIS Gets the value of a given ConfigurationItem property by key .DESCRIPTION A ConfigurationItem may have zero or more Property objects in the Properties array. Each property has a key name and a value. Since the Properties property on a ConfigurationItem has no string-based indexer, you are required to search the array of properties for the one with the Key you're interested in, and then get the Value property of it. This cmdlet is a simple wrapper which does the Where-Object for you, and throws an error if the Key does not exist. .PARAMETER InputObject A [VideoOS.ConfigurationApi.ClientService.ConfigurationItem] with a property to be retrieved. .PARAMETER Key A string representing the key of the property from which the value should be retrieved. .EXAMPLE PS C:\> $description = Get-ConfigurationItem -Path / | Get-ConfigurationItemProperty -Key Description Gets a ConfigurationItem representing the Management Server, and returns the Description value. The alternative is to do ((Get-ConfigurationItem -Path /).Properties | Where-Object Key -eq Description).Value. #> [CmdletBinding()] param( [Parameter(Mandatory, ValueFromPipeline)] [VideoOS.ConfigurationApi.ClientService.ConfigurationItem] [ValidateNotNullOrEmpty()] $InputObject, [Parameter(Mandatory)] [string] [ValidateNotNullOrEmpty()] $Key ) process { $property = $InputObject.Properties | Where-Object Key -eq $Key if ($null -eq $property) { Write-Error -Message "Key '$Key' not found on configuration item $($InputObject.Path)" -TargetObject $InputObject -Category InvalidArgument return } $property.Value } } |