Skip to content

Instantly share code, notes, and snippets.

@ilandcloud
Created October 12, 2016 14:57
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/88247a9f789b36b5e3d3e973695b0b4c to your computer and use it in GitHub Desktop.
Save ilandcloud/88247a9f789b36b5e3d3e973695b0b4c to your computer and use it in GitHub Desktop.
Connect-CIServer -server ‘sin01.ilandcloud.com’ -User ‘username’ -Password ‘password’ -Org ‘YourOrg
# Read existing CSV file with metadata requirements
$file = 'c:\temp\metadata.csv'
# Read the CSV file into an array
$requirements = Import-Csv -Path $file
# Trundle through the array, getting the requirements per vApp
foreach ($requirement in $requirements){
$vApp = $requirement.vApp
$Days = $requirement.Days
$StopTime = $requirement.StopTime
$StartTime = $requirement.StartTime
$AutoOnOff = $requirement.AutoOnOff
# Apply the metadata to the vApp (will overwrite previous key/value pairs)
$target = Get-CIVApp -Name $vApp
New-CIMetaData -Key "Days" -Value $Days -CIObject $target
New-CIMetaData -Key "StopTime" -Value $StopTime -CIObject $target
New-CIMetaData -Key "StartTime" -Value $StartTime -CIObject $target
New-CIMetaData -Key "AutoOnOff" -Value $AutoOnOff -CIObject $target
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment