If you change the last line of the script into:
} | Export-CSV -Path VMsReport.csv -NoTypeInformation -UseCulture
then you will save the output as a .csv file called VMsReport.csv.
If you have a .csv file called VMs.csv. that has a header row with a column header "VM", like:
VMVM1
VM2
then you can get the ESX host, cluster and datastores of the VM's in the .csv file with:
Import-Csv -Path VMs.csv | ForEach-Object { Get-VM -Name $_.VM | Select-Object -Property Name,VMHost, @{N="Cluster";E={$_.VMHost.Parent}}, @{N="Datastores";E={[string]::Join(',',($_|Get-Datastore))}} }
Regards, Robert
Robert,
Can you modify a little bit to gereate the out put in csv format.
thanks
vmk
If you change the last line of the script into:
} | Export-CSV -Path VMsReport.csv -NoTypeInformation -UseCulture
then you will save the output as a .csv file called VMsReport.csv.
Robert,
I did but its taking little bit more time to generate report.
Import-Csv -Path C:\VMs.csv | ForEach-Object {
Get-VM -Name $_.VM | Select-Object -Property Name,VMHost,
@{N="Cluster";E={$_.VMHost.Parent}},
@{N="Datastores";E={[string]::Join(',',($_|Get-Datastore))}}
} | Export-Csv "C:\Vm-datastore.csv" -noTypeInformation
thanks
vmk