If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.
$vmObj = Get-vm $vms
$newlist = $vmobj
foreach($active in ($vmObj | where {$_.powerstate -ne "PoweredOn"}) ){
## remove VM that power is not On
Remove-VM -VM $delete -DeleteFromDisk -Confirm:$false -RunAsync | Out-Null
}
}
The above script will NEVER remove a server that is power on..
$vmObj | where {$_.powerstate -eq "PoweredOn"}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Join the community of 500,000 technology professionals and ask your questions.