Hello I have the following code but exports all VM that are powered on and off. Is there anyway to export only the VMs that are powered On ?
$clusterName = "Whatever"
Get-Cluster -Name $clusterName | Get-VM | Select Name, @{N="Cluster";E={$clusterName}}, @{N="ESX Host";E={Get-VMHost -VM $_ | Select -ExpandProperty Name}}, @{N="Datastore";E={Get-Datastore -VM $_ | Select -ExpandProperty Name}} |Export-Csv C:\report.csv -NoTypeInformation -UseCulture
Thanks,