Reply to Message

View discussion in a popup

Replying to:
RvdNieuwendijk
Leadership
Leadership

The vCenter Server name is in the Uid property. You can use the string Split() method to extract the vCenter Server name:

Get-VM | Select-Object Name,@{N="vCenter";E={$_.Uid.Split('@')[1].Split(':')[0]}}
Get-VMHost | Select-Object Name,@{N="vCenter";E={$_.Uid.Split('@')[1].Split(':')[0]}}

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition