From 2bc35885bc11f5c34ec933a7c25ba636528083fb Mon Sep 17 00:00:00 2001 From: Martin O'Reilly Date: Wed, 17 Apr 2019 00:43:04 +0100 Subject: [PATCH] Read .pol file with -AsBytestream flag in PS v6+ --- GPRegistryPolicyParser.psm1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GPRegistryPolicyParser.psm1 b/GPRegistryPolicyParser.psm1 index 4b1143a..254c10e 100644 --- a/GPRegistryPolicyParser.psm1 +++ b/GPRegistryPolicyParser.psm1 @@ -184,7 +184,12 @@ Function Parse-PolFile $index = 0 [string] $policyContents = Get-Content $Path -Raw - [byte[]] $policyContentInBytes = Get-Content $Path -Raw -Encoding Byte + + if ($psversiontable.PSVersion.Major -lt 6) { + [byte[]] $policyContentInBytes = Get-Content $Path -Raw -Encoding Byte + } else { + [byte[]] $policyContentInBytes = Get-Content $Path -AsByteStream + } # 4 bytes are the signature PReg $signature = [System.Text.Encoding]::ASCII.GetString($policyContents[0..3])