Changing Encoding on a file -piping commands together get different results RRS feed

  • Question

  • I am trying to change the encoding on a set of files.  I can do it this way and it works:

     $content = get-content -path "c:\aa\ssrsmaintpageup.ps1" 

     $content | out-file -filepath "c:\aa\SSRSMaintPageUp.ps1" -encoding utf8

    But when I pipe the Get with the Out - it wipes out the file and sets it to zero bytes.  Why?

    get-content -path "c:\aa\SSRSMaintPageUp.ps1" | out-file -filepath "c:\aa\SSRSMaintPageUp.ps1" -encoding utf8

    I'm sure it is my misunderstanding of what is getting piped to the Out-file command.

    Friday, February 12, 2016 2:48 PM


  • Try it like this:

    (get-content c:\aa\ssrsmaintpageup.ps1 )| out-file c:\aa\SSRSMaintPageUp.ps1 -encoding utf8


    • Proposed as answer by Mike Laughlin Friday, February 12, 2016 3:46 PM
    • Marked as answer by dcybela Friday, February 12, 2016 6:21 PM
    Friday, February 12, 2016 3:29 PM