Skip to content
This repository was archived by the owner on Feb 24, 2021. It is now read-only.

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion GPRegistryPolicyParser.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down