I've found it a lot easier to do this via PowerCLI...
$vc = vcenter1
$dc = "Datacenter"
Connect-VIServer $vc
# Gets the list of all VMs in the datacenter (except the vCenter VM itself)
$vms = Get-datacenter -Name $dc | Get-VM | where {$_.Name -ne $vc -and $_.PowerState -eq "PoweredOn"}
# Shuts down the VMs in the datacenter that are in a powered on state.
Foreach ($vm in $vms){
if($vm.ExtensionData.Config.Tools.ToolsVersion -ne "0"){
#gracefully shutdown
Shutdown-VMGuest -VM $vm -Confirm:$false
sleep -Seconds 60
}
#forcefully stopping VM
Stop-VM -VM $vm -Confirm:$false
}
# Shutdown vCenter VM (Comment out if vCenter is not virtual)
sleep -seconds 120
Shutdown-VMGuest -VM $vc-Confirm:$false