Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote a powershell script to retrive NAME & PATH of VM's(virtula machine) and save them in CSV file, But when ever there is '/' it displays as '%5c' i have no idea why its showing like that and I dont know how to change it.

Here is my powershell 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 $_) -replace "^.*?Resources"}} `
| ConvertTo-Csv -NoTypeInformation `
| Select-Object -Skip 1 `
| Set-Content -Path C:\izaz\test.csv
Posted

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