Skip to content

Instantly share code, notes, and snippets.

@gowatana
Created April 30, 2023 14:53
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 gowatana/8446e8ef5ecd3b29c9a2051d997b5e88 to your computer and use it in GitHub Desktop.
Save gowatana/8446e8ef5ecd3b29c9a2051d997b5e88 to your computer and use it in GitHub Desktop.
# Usage: 02_delete_vcd_vapp.ps1 config.ps1
# Author: @gowatana
$config_ps1_file = $args[0]
if($args.Count -ne 1){"Config .ps1 NOT found."; exit 1}
Get-ChildItem -ErrorAction:Ignore $config_ps1_file | Out-Null
if($? -eq $false){"Config $config_ps1_file NOT found."; exit 1}
. $config_ps1_file
$vapp_name_list = $vapp_number_start..$vapp_number_end | % {
$vapp_number_strings = $_.ToString("000")
$vapp_name = $vapp_name_prefix + "-" + $vapp_number_strings
$vapp_name
}
$vapp_name_list | % {
$vapp_name = $_
Write-Host "Stop vApp: $vapp_name"
Get-CIVApp $vapp_name | Where {$_.Status -ne "PoweredOff"} | Stop-CIVApp -Confirm:$false | Out-Null
Write-Host "Delete vApp: $vapp_name"
Get-CIVApp $vapp_name | Remove-CIVApp -Confirm:$false -RunAsync | Out-Null
}
@gowatana
Copy link
Author

下記の投稿むけ。

VMware Cloud Director 10.4 を PowerCLI で操作してみる。Part-05 vApp クローン スクリプトの例
https://vm.gowatana.jp/entry/2023/04/30/235923

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment