Hello I am new to the PowerCLI and Powershell in general....I am looking to create a report that will list the guest, the cluster it is on and the lun or datastore it is on.
I have a specific set of VM I am looking to get this data from.
I created a variable for the list of vm (get-content from a txt file) however when I try to pipe that to Get-VM it does not work because it is a string.
How would you recommend this be done?
Thanks!
Do I need to create a new variable that is something like get-vm if -name is in servers.txt (sorry just thinking outloud).
That is correct, you can't pipe a string of names to the Get-VM cmdlet.
But there are alternatives:
$vms = Get-Content .\vmnames.txt
Get-VM -Name $vms
or
Get-Content .\vmnames.txt | %{
Get-VM $_
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Awesome!
So now pardon my noobieness I only want to show parts of the get-vm info (ie name, datastore, host).
Thanks for the rapid response.
Sorry for the million questions…I am needing more and more info now.
Here is what I have:
Text file with Servername and scan time
Example: Server01 Sunday 16:00
I need to create a report that will display the following information in the following format.
Servername
Scan time
Datastore
Clustername
And if at all possible dump it out to a CSV so I can sort by servername or datastore, etc.
Thanks again!
1) To only display part of the properties, use the Select-Object cmdlet.
Get-VM -Name MyVM | Select Name,NumCPU,MemoryMB
2) Do you have any servers that have blanks in their names ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No I do not