1 Replies - 757 Views - Last Post: 16 July 2015 - 08:18 AM Rate Topic: -----

#1 ejji09   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 05-May 15

How to convert '%5c' delimted CSV file to '/' delimete

Posted 16 July 2015 - 01:25 AM

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.

Please see the attachmnet

Here is my powershell CODE:
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

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: How to convert '%5c' delimted CSV file to '/' delimete

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,157
  • Joined: 12-June 08

Re: How to convert '%5c' delimted CSV file to '/' delimete

Posted 16 July 2015 - 08:18 AM

That is typically indicative of UTF-8 (unicode) encoding.

From what I understand you can use the System.IO.File's WriteAllLines to jack with the encoding.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1