Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
am using the below script to retrieve the NAME and PATH of the VM's and in the PATH am getting the full length path which i dont want it, i just need the path which is displaying after the Resources/

here is my code:
PHP
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 $_}}


output :
http://s1065.photobucket.com/user/Izaz_Ahmed/media/Capture_zpsooe7ykac.jpg.html
Posted

1 solution

Just Replace this
C#
Get-VM | Select Name,
    @{N="Path";E={(Get-Path -Object $_) -replace "^.*?Resources"}}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900