Morning, (for those in the US )
Question on PowerState. I am trying to shutdown and delete a number of VMs. Script is simple, but I want to have a catch if the VM is running, turn off the power. I cant get it to work. I have checked a number of sites, pretty sure my code is correct. I went ahead and created a simple "Is the server up" script and that is in fact whats failing. My shutdown commands and delete commands are working fine on their own, only when paired with a PowerState does it fail.
Here is the simple script:
Foreach ($vm in $list)
{
IF ($vm.PowerState -eq "PoweredOn")
{
Write-Output $vm "IS ON"
}
ELSE
{
Write-Output $vm "IS OFF"
}
}
The simple script fails every time. All servers return "IS OFF". The servers I am deleting are Linux boxes.. does VMTools have to be installed for PowerState to return a correct value??
Thanks,
Boston Tech Guy