Hi,
I need a script or command in order to gather the following infos from a list of VM (datacenter name, cluster name, vm name and vm uuid).
I have used this command which works fine :
Get-Cluster **** | Get-VM | Select @{N=”Datacenter”;E={Get-Datacenter -VM $_}}, @{N="Cluster";E={Get-Cluster -VM $_}},Name, @{N="VMUUID";E={(Get-View $_.Id).config.uuid}} | Export-CSV "C:\DC-$(Get-Date -f ddMMyyyy).csv" -NoTypeInformation
Except that now I need to use a list of VM from a text file to retrieve the above infos.
Could you please help me out?
Hi
I always use rvtools, think is more simple.
https://www.robware.net/rvtools/
Thanks for your suggestion Diego. RVTools is a great tool but it retrieves a full list of VMs where you may have duplicate vm names such as abc, abc- or abc_.
Based upon the vm.txt list, I'll be able to gather the necessary info needed.
Welcome to the Community,
Please see whether Re: Script to get VMs name, host and IP filtered is what you are looking for.
Hint: Whenever searching for a script that works on vSphere, include PowerCLI and lucd as keywords in your search.
André
Discussion moved from VMware vCenter™ to VMware PowerCLI
This combines the .txt file and your original code.
The text file assumes 1 VM name per line.
Select @{N = ”Datacenter”; E = {(Get-Datacenter -VM $_).Name}},
@{N = "Cluster"; E = {(Get-Cluster -VM $_).Name}}, Name,
@{N = "VMUUID"; E = {$_.ExtensionData.config.uuid}} |
Export-CSV "C:\DC-$(Get-Date -f ddMMyyyy).csv" -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks a.p it works for me hurray!
Is there any possibility to remove duplicate vm entries if ever it was present in the vm text file list unknowingly?
Yes, you can use e.g. Get-Unique to do this.
André