I'm trying to export a list of VMs and their SRM state according to this script from VMware below. However, how do I output the list/report to a csv or an excel file?
vSphere 6.0 Documentation Center
Generate a report of the protected virtual machines.
$protectionGroups | % {
$protectionGroup = $_
$protectionGroupInfo = $protectionGroup.GetInfo()
# The following command lists the virtual machines associated with a protection group
$protectedVms = $protectionGroup.ListProtectedVms()
# The result of the above call is an array of references to the virtual machines at the vSphere API
# To populate the data from the vSphere connection, call the UpdateViewData method on each virtual machine view object
$protectedVms | % { $_.Vm.UpdateViewData() }
# After the data is populated, use it to generate a report
$protectedVms | %{
$output = "" | select VmName, PgName
$output.VmName = $_.Vm.Name
$output.PgName = $protectionGroupInfo.Name
$output
}
} | Format-Table @{Label="VM Name"; Expression={$_.VmName} }, @{Label="Protection group name"; Expression={$_.PgName} }