Hello,
-
There are (as always) several ways to go about this. If using the Get-VMHost cmdlet, there are a few different properties that contain the vCenter info within their values. Some such properties: ".Uid", ".Client.ConnectionId", and ".Client.ServerUri". So, you could grab the vCenter (or VIServer) name from any of those properties. For example:
Get-VMHost | select Name,@{n="vCenter"; e={$_.Client.ServerUri.Split("@")[1]}}
The ".Client.ServerUri" value there is something like "443@myvcenter.domain.com", so the calculated property splits on the "@" and then returns the item at index 1 (the part after the "@"), resulting in "myvcenter.domain.com".
Then, of course, add in your other properties that you are selecting/calculating. How does that do for you?