Hi,
Is there a way to get the name of the vCenter that a VM is managed by, if I start with the VM name?
I have 2 vCenters joined in linked mode, and connect to them both at the same time when I run scripts. I would like to add a field in my output such as VMname, vCenter, VMhost, etc
I had an idea to track the parent folders; but seem to stop at datacenter.
thanks.
You can retrieve the vCenter Server name from the Uid property of the virtual machine object. Like this:
(Get-VM YourVMName).Uid.Split(":")[0].Split("@")[1]
In PowerCLI 4.1 you can extend the virtual machine object with a vCenterServer property. Like this:
New-VIProperty -Name vCenterServer -ObjectType VirtualMachine -Value {$Args[0].Uid.Split(":")[0].Split("@")[1]} Get-vm YourVMName | Select-Object -Property Name,vCenterServer
Regards, Robert
You can retrieve the vCenter Server name from the Uid property of the virtual machine object. Like this:
(Get-VM YourVMName).Uid.Split(":")[0].Split("@")[1]
In PowerCLI 4.1 you can extend the virtual machine object with a vCenterServer property. Like this:
New-VIProperty -Name vCenterServer -ObjectType VirtualMachine -Value {$Args[0].Uid.Split(":")[0].Split("@")[1]} Get-vm YourVMName | Select-Object -Property Name,vCenterServer
Regards, Robert
Note that this will only work in PowerCLI 4.1 which introduced the Uid property.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference