Created
June 3, 2021 15:29
-
-
Save sandeep-sr/43609439c5991ac3324cc3f71aa826fe to your computer and use it in GitHub Desktop.
powercli - Delete multiple VM’s
This file contains hidden or 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
Get-Module -ListAvailable *vm*|Import-Module | |
$cred=Get-Credential | |
Connect-VIServer vcenter02 -Credential $cred | |
$deletevmlist=Get-Content C:\temp\delete.txt | |
foreach($deletevm in $deletevmlist) | |
{ | |
write-output ("$deletevm is deleting...") | |
get-cluster cluster02|get-vm $deletevm |Remove-VM -DeletePermanently -Confirm:$false -RunAsync| out-null | |
Start-Sleep 10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment