Skip to content

Commit

Permalink
Update Parse-PolicyFile.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
gtworek authored Sep 27, 2019
1 parent 7694c49 commit e511a0e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions GPO/Parse-PolicyFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ if (Test-Path ($polFile.FullName))
Write-Host ("[??? POL] Not looking like POL file "+$polFile.FullName) -ForegroundColor Red
$polrow = New-Object psobject
$polrow | Add-Member -Name "FullName" -MemberType NoteProperty -Value $polFile.FullName
$polrow | Add-Member -Name "Root" -MemberType NoteProperty -Value "???"
$polrow | Add-Member -Name "Hive" -MemberType NoteProperty -Value "???"
$polrow | Add-Member -Name "Key" -MemberType NoteProperty -Value "???"
$polrow | Add-Member -Name "Value" -MemberType NoteProperty -Value "???"
$polrow | Add-Member -Name "Data" -MemberType NoteProperty -Value "???"
}
else
{
#Root (HKLM/HKCU) to be determined from name, ? for unknown. stupid but works
$POLroot = "?"
#Hive (HKLM/HKCU) to be determined from name, ? for unknown. stupid but works
$POLHive = "?"
if ($polFile.FullName -like "*}_Machine_Registry.pol")
{
$POLroot = "HKLM"
$POLHive = "HKLM"
}
if ($polFile.FullName -like "*}_User_Registry.pol")
{
$POLroot = "HKCU"
$POLHive = "HKCU"
}
#[key;value;type;size;data]
$polbytes = $polbytes[8..($polbytes.Count)]
Expand All @@ -45,7 +45,7 @@ if (Test-Path ($polFile.FullName))

$polrow = New-Object psobject
$polrow | Add-Member -Name "FullName" -MemberType NoteProperty -Value $polFile.FullName
$polrow | Add-Member -Name "Root" -MemberType NoteProperty -Value $POLroot
$polrow | Add-Member -Name "Hive" -MemberType NoteProperty -Value $POLHive
$polrow | Add-Member -Name "Key" -MemberType NoteProperty -Value "??"
$polrow | Add-Member -Name "Value" -MemberType NoteProperty -Value "??"
$polrow | Add-Member -Name "Type" -MemberType NoteProperty -Value "??"
Expand Down Expand Up @@ -142,6 +142,10 @@ if (Test-Path ($polFile.FullName))
while (!(($poldata[($poldata.Count-1)]) -or ($poldata[($poldata.Count-2)]))) #if double \0 at the end
{
$poldata = $poldata[0..($poldata.Count-3)]
if ($poldata.Count -le 4)
{
break
}
}
<#
$poldata = $poldata[0..($poldata.Count-3)]
Expand All @@ -165,7 +169,7 @@ if (Test-Path ($polFile.FullName))
$arrtmp2 += $polrow
$polrow = New-Object psobject #re-init data for row
$polrow | Add-Member -Name "FullName" -MemberType NoteProperty -Value $polFile.FullName
$polrow | Add-Member -Name "Root" -MemberType NoteProperty -Value $POLroot
$polrow | Add-Member -Name "Hive" -MemberType NoteProperty -Value $POLHive
$polrow | Add-Member -Name "Key" -MemberType NoteProperty -Value "??"
$polrow | Add-Member -Name "Value" -MemberType NoteProperty -Value "??"
$polrow | Add-Member -Name "Type" -MemberType NoteProperty -Value "??"
Expand Down

0 comments on commit e511a0e

Please sign in to comment.