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 $_) -replace "^.*?Resources"}} ` | ConvertTo-Csv -NoTypeInformation ` | Select-Object -Skip 1 ` | Set-Content -Path C:\izaz\test.csv
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)