Skip to content

Instantly share code, notes, and snippets.

@ilandcloud
Last active October 13, 2016 13:51
Show Gist options
  • Save ilandcloud/515c1714ec7d9ef60f162e6389a6b476 to your computer and use it in GitHub Desktop.
Save ilandcloud/515c1714ec7d9ef60f162e6389a6b476 to your computer and use it in GitHub Desktop.
This is a custom-developed cmdlet from velemental.com. This can be referenced as part of your Powershell profile, or just included at the top of your script. http://velemental.com/2012/03/29/managing-metadata-in-vcd-with-powercli/
Function Get-CIMetaData {
<#
.SYNOPSIS
Retrieves all Metadata Key/Value pairs.
.DESCRIPTION
Retrieves all custom Metadata Key/Value pairs on a specified vCloud object
.PARAMETER CIObject
The object on which to retrieve the Metadata.
.PARAMETER Key
The key to retrieve.
.EXAMPLE
PS C:\> Get-CIMetadata -CIObject (Get-Org Org1)
#>
param(
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[PSObject[]]$CIObject,
$Key
)
Process {
Foreach ($Object in $CIObject) {
If ($Key) {
($Object.ExtensionData.GetMetadata()).MetadataEntry | Where {$_.Key -eq $key } | Select @{N="CIObject";E={$Object.Name}}, Key, Value
} Else {
($Object.ExtensionData.GetMetadata()).MetadataEntry | Select @{N="CIObject";E={$Object.Name}}, Key, Value
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment