function Get-Path{ param($Object) $path = $object.Name $parent = Get-View $Object.ExtensionData.ResourcePool while($parent){ $path = $parent.Name + "/" + $path if($parent.Parent){ $parent = Get-View $parent.Parent } else{$parent = $null} } $path } Get-VM | Select Name, @{N="Path";E={Get-Path -Object $_}}
Get-VM | Select Name, @{N="Path";E={(Get-Path -Object $_) -replace "^.*?Resources"}}
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)