VMware Cloud Community
galoi9
Contributor
Contributor

DataCenter for a VM

Can someone point me to a sample script to retrieve the datacenter that a given VM resides in?

Reply
0 Kudos
1 Reply
kunaludapi
Expert
Expert

Get-Datacenter DatastoreName | Get-VM

Or

Get-VM VMname | Select-Object Name, @{N="Datacenter"; E={$_ | Get-Datacenter}}

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
Reply
0 Kudos