$clusters = get-cluster aforeach ($cluster in $clusters) { $vmhosts = $cluster | get-vmhost $firsthost = $vmhosts[0] $datastores = $firsthost | get-datastore | % {(Get-View $_.ID).summary} foreach ($datastore in $datastores) { $datastore | select-object @{Name = "Date"; Expression = {get-date}}, @{Name = "Cluster"; Expression = {$cluster.name}}, URL, Name, Freespace, Capacity } }
Can this be exported to a specific location? and in what formats?
You can output the results of a PowerCLI script in various ways like text, csv or html. It is also posible to specify the location. Take a look at the Out-File, Export-Csv or ConvertTo-Html cmdlets with Get-Help.
Most excellent you just cut my Search and Find efforts by a few hours as I don't have to type all this in now I was able to do a manual command get-datastore and output that in the CSV format and get what I need for now. However, when running the script I get the following error.
Can you shed some light on this? - got it. I was attempting to run this from within Quest PowerGUI script editor and it did not know about the methods of vSphere. When I open the VMware vSphere PowerCLI and run the ps1 script from within that it all works. ha... Newbie I am.