Skip to content

Instantly share code, notes, and snippets.

@ilandcloud
Created October 12, 2016 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilandcloud/1d17355bd8f38dd5d0993550b3841db0 to your computer and use it in GitHub Desktop.
Save ilandcloud/1d17355bd8f38dd5d0993550b3841db0 to your computer and use it in GitHub Desktop.
The ‘AutoOnOff’ key on its own can be used for a really simple script that checks for the existence of the key and the value being set to ‘Yes’, and will then shut it down.
$vApps = Get-CIVApp
$Metadatas = Get-CIMetaData -CIObject $vApps
foreach ($Metadata in $Metadatas) {
$vApp = $Metadata.CIObject
$Key = $Metadata.Key
$Value = $Metadata.Value
if ($Value -like 'Yes') {write-host 'Stopping vApp....',$vApp}
if ($Value -like 'Yes') {Stop-CIVApp -VApp $vApp -Confirm:$false}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment