PoshCode Archive  Artifact [179553358d]

Artifact 179553358d145d156db2e3d40f3554cf183da1bd6822442cc065ad67bbcf1863:

  • File Convert-File-Encoding.ps1 — part of check-in [5e48338c3b] at 2018-06-10 13:18:32 on branch trunk — R.Vantrease ver 1.0 – The source control I use does not understand the default encoding that PowerShell_ISE saves scripts in (Unicode Big Endian), so I wanted a way to quickly convert my scripts to a friendlier encoding. I wrote the following little ditty to convert all the PowerShell scripts and module files to ASCII encoding. (user: Richard Vantreas size: 924)

# encoding: ascii
# api: powershell
# title: Convert File Encoding
# description: R.Vantrease ver 1.0 – The source control I use does not understand the default encoding that PowerShell_ISE saves scripts in (Unicode Big Endian), so I wanted a way to quickly convert my scripts to a friendlier encoding.  I wrote the following little ditty to convert all the PowerShell scripts and module files to ASCII encoding.
# version: 0.1
# author: Richard Vantreas
# license: CC0
# x-poshcode-id: 2999
# x-archived: 2016-08-03T11:04:02
# x-published: 2012-10-12T15:14:00
#
#
cd c:\windows\temp\common

foreach($File in get-childitem | where-object{($_.Extension -ieq '.PS1') -or ($_.Extension -ieq '.PSM1')})
{
    $FileName = $File.Name
    $TempFile = "$($File.Name).ASCII"

    get-content $FileName | out-file $TempFile -Encoding ASCII 

    remove-item $FileName

    rename-item $TempFile $FileName
}