GPRegistryPolicy icon indicating copy to clipboard operation
GPRegistryPolicy copied to clipboard

Read .pol file with -AsBytestream flag in PS v6+

Open martintoreilly opened this issue 5 years ago • 1 comments

As of Powershell version 6, reading the contents of a file using Get-Content <path-to-file> -Raw -Encoding Byte no longer works. Get-Content <path-to-file> -AsByteStream should be used instead.

See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-content?view=powershell-6#parameters

martintoreilly avatar Apr 16 '19 23:04 martintoreilly

It might be better for my check to be the other way round (check if version is greater than or equal to v6) as it seems psversiontable only exists from Powershell v2 according to https://stackoverflow.com/questions/1825585/determine-installed-powershell-version

martintoreilly avatar Apr 16 '19 23:04 martintoreilly