System.IO.File.ReadAllText method and Default encoding with Nano server

You may find that running the following command on Nano will fail
[System.IO.File]::ReadAllText($path, [System.Text.Encoding]::Default)

Exception calling "ReadAllText" with "2" argument(s): "Value cannot be null.

This is because the Default encoding is not longer in the list of valid encoding types


To resolve this issue either call ReadAllText with no parameter, or a different encoding parameter. Or better still use the Get-Content cmdlet which takes the pain away from this encoding.

Comments

Popular posts from this blog

SOLVED: Exchange Online Management PowerShell Connect-ExchangeOnline bug "A window handle must be configured. See https://aka.ms/msal-net-wam#parent-window-handles"

System error 86 has occurred. The specified network password is not correct.

The security identifier of the "NT SERVICE\WdiServiceHost" account is "S-1-5-80-3139157870-2983391045-3678747466-658725712-1809340420"