System.IO.File::ReadAllText slurps the content of an entire file and returns it as a System.String object. System.Text.Encoding object that specifies the file's encoding. $absolute_path = convert-path .\readme.txt $content = [IO.File]::ReadAllText($absolute_path, [System.Text.Encoding]::GetEncoding('iso-8859-1')) [IO.File]::WriteAllText($absolute_path, $content, [Text.Encoding]::UTF8)
get-content allows to read the entire content of a file with the -raw parameter. ReadAllText in combination with WriteAllText might be used to change line endings in a file from DOS convention to UNIX convention, or vice versa.