Quantcast
Channel: VMware Communities: Message List - VMware vCloud Director
Viewing all articles
Browse latest Browse all 7719

Re: Is there any automated way of deleting a list of vApps from an org?

$
0
0

With powercli something like this should work...  (This is assuming sys admin level access, if not you need to make some changes to the connect line)

(Script not tested but should be close and get you going)

 

#This will attempt to stop and DELETE all vapps in an org... no going back so be careful

 

$vCloudServer = "mycloud.company.com"

$vCloudAdminUser = "Administrator"

$vCloudPw = "thepassword"

$orgName = "The Org"

Connect-CIServer -Server $vCloudServer -user $vCloudAdminUser -password $vCloudPw

$org = Get-Org -Name $orgName

#getPoweredOn to shutdown

$poweredOnVapps = $org | Get-CIVapp | Where {$_.Status -ne "PoweredOff"}

Write-Host "Shutdown..."

foreach ($v in $poweredOnVapps) {

  Write-Host $v.Name

#might need to set RunAsync to $false if this is to much for the system... I normally just add a sleep in (only reason this sleep is here)

  Stop-CIVApp -VApp $v -RunAsync:$true -Confirm:$false -WhatIf:$false

   sleep 15

}

#rather than script the wait... just wait some time and hope it was plenty - can run script again after if needed

sleep 30

$vapps = $org | Get-CIVapp

Write-Host "Now delete..."

foreach ($v in $poweredOnVapps) {

  Write-Host $v.Name

#might need to set RunAsync to $false if this is to much for the system... I normally just add a sleep in (only reason this sleep is here)

  Remove-CIVApp -VApp $v -RunAsync:$true -Confirm:$false -WhatIf:$false

   sleep 15

}

Write-Host "Done"


Viewing all articles
Browse latest Browse all 7719

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>