Skip to content

Instantly share code, notes, and snippets.

@royashbrook
Created January 10, 2022 21:39
Show Gist options
  • Save royashbrook/9b0efe788049a24920f3ef41cab318f6 to your computer and use it in GitHub Desktop.
Save royashbrook/9b0efe788049a24920f3ef41cab318f6 to your computer and use it in GitHub Desktop.
Simple PS script to get encoding on a file using streamreader
function Get-FileEncoding ($FilePath){
New-Object System.IO.StreamReader $FilePath -OutVariable Stream |
Select-Object -ExpandProperty CurrentEncoding |
Select-Object -ExpandProperty BodyName
$Stream.Dispose()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment