Last active
October 13, 2016 13:51
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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