Search notes:

System.IO.File::ReadAllText

System.IO.File::ReadAllText slurps the content of an entire file and returns it as a System.String object.
The first parameter specifies the path to the file to be read.
The optional second parameter is a System.Text.Encoding object that specifies the file's encoding.

Change a file's encoding

ReadAllText along with WriteAllText can be used to change the encoding of a file:
$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)

See also

ReadAllBytes() and WriteAllBytes()
System.Text.Encoding
The PowerShell cmdlet 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.

Index