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

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Enable function lock for F1-F12 on HP ZBook mobile workstations