Skip to content

Commit

Permalink
Update WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemyslawKlys committed Jun 29, 2020
1 parent 9030233 commit 9e837d2
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 34 deletions.
24 changes: 18 additions & 6 deletions Examples/Example-29-FindGPO-FromDisk-Notranslation.ps1
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force

# Use Save-GPOZaurrFiles -GPOPath $ENV:USERPROFILE\Desktop\GPOExport

$OutputNoTranslation = Invoke-GPOZaurr -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExportTest' -NoTranslation
#$OutputNoTranslation = Invoke-GPOZaurr -GPOPath $Env:UserProfile\Desktop\GPOExport -NoTranslation
#$OutputNoTranslation = Invoke-GPOZaurr -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExportTest' -NoTranslation
$OutputNoTranslation | Format-Table *

<#
New-HTML {
foreach ($GPOCategory in $OutputNoTranslation.Keys) {
New-HTMLTab -Name $GPOCategory {
if ($Output["$GPOCategory"] -is [System.Collections.IDictionary]) {
if ($OutputNoTranslation["$GPOCategory"] -is [System.Collections.IDictionary]) {
foreach ($GpoSettings in $OutputNoTranslation["$GPOCategory"].Keys) {
New-HTMLTab -Name $GpoSettings {
New-HTMLTable -DataTable $OutputNoTranslation[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $Key
New-HTMLTable -DataTable $OutputNoTranslation[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $GpoSettings
}
}
} else {
New-HTMLTable -DataTable $OutputNoTranslation[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $Key
New-HTMLTable -DataTable $OutputNoTranslation[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $GpoSettings
}
}
}
} -Online -ShowHTML -FilePath $Env:UserProfile\Desktop\OutputFromFindGPO-NoTranslationFromDisk.html
} -Online -ShowHTML -FilePath $Env:UserProfile\Desktop\OutputFromFindGPO-NoTranslationFromDisk.html
#>
foreach ($GPOCategory in $OutputNoTranslation.Keys) {
if ($OutputNoTranslation["$GPOCategory"] -is [System.Collections.IDictionary]) {
foreach ($GpoSettings in $OutputNoTranslation["$GPOCategory"].Keys) {
ConvertTo-Excel -DataTable $OutputNoTranslation[$GPOCategory][$GpoSettings] -AllProperties -ExcelWorkSheetName $GpoSettings -FilePath $Env:UserProfile\Desktop\Export\$GpoSettings.xlsx -AutoFilter -AutoFit
}
} else {
ConvertTo-Excel -DataTable $OutputNoTranslation[$GPOCategory][$GpoSettings] -AllProperties -ExcelWorkSheetName $GpoSettings -FilePath $Env:UserProfile\Desktop\Export\$GpoSettings.xlsx -AutoFilter -AutoFit
}
}
36 changes: 36 additions & 0 deletions Examples/Example-29-FindGPO0.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force

#Invoke-GPOZaurr -OutputType Excel, Object, HTML -Open | Format-Table
$Output = Invoke-GPOZaurr -GPOPath $Env:USERPROFILE\Desktop\GPOExport -NoTranslation #| Format-Table
#$Output.Count



<# 4073 files - 212MB / no translation
Days : 0
Hours : 0
Minutes : 0
Seconds : 51
Milliseconds : 756
Ticks : 517566534
TotalDays : 0,000599035340277778
TotalHours : 0,0143768481666667
TotalMinutes : 0,86261089
TotalSeconds : 51,7566534
TotalMilliseconds : 51756,6534
#>

<# 4073 files - 212MB / no translation / But with 2 diff types ($OutputByCategory / $OutputByGPO)
Days : 0
Hours : 0
Minutes : 0
Seconds : 53
Milliseconds : 246
Ticks : 532466109
TotalDays : 0,00061628021875
TotalHours : 0,01479072525
TotalMinutes : 0,887443515
TotalSeconds : 53,2466109
TotalMilliseconds : 53246,6109
#>
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force

$Output = Invoke-GPOZaurr #-NoTranslation
$Output | Format-Table

New-HTML {
foreach ($GPOCategory in $Output.Keys) {
New-HTMLTab -Name $GPOCategory {
if ($Output["$GPOCategory"] -is [System.Collections.IDictionary]) {
foreach ($GpoSettings in $Output["$GPOCategory"].Keys) {
New-HTMLTab -Name $GpoSettings {
New-HTMLTable -DataTable $Output[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $Key
New-HTMLTable -DataTable $Output[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $GpoSettings
}
}
} else {
New-HTMLTable -DataTable $Output[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $Key
New-HTMLTable -DataTable $Output[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $GpoSettings
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force

$Output = Invoke-GPOZaurr -NoTranslation
$Output | Format-Table

New-HTML {
foreach ($GPOCategory in $Output.Keys) {
New-HTMLTab -Name $GPOCategory {
if ($Output["$GPOCategory"] -is [System.Collections.IDictionary]) {
foreach ($GpoSettings in $Output["$GPOCategory"].Keys) {
New-HTMLTab -Name $GpoSettings {
New-HTMLTable -DataTable $Output[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $Key
New-HTMLTable -DataTable $Output[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $GpoSettings
}
}
} else {
New-HTMLTable -DataTable $Output[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $Key
New-HTMLTable -DataTable $Output[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $GpoSettings
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ New-HTML {
if ($Output["$GPOCategory"] -is [System.Collections.IDictionary]) {
foreach ($GpoSettings in $Output["$GPOCategory"].Keys) {
New-HTMLTab -Name $GpoSettings {
New-HTMLTable -DataTable $Output[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $Key
New-HTMLTable -DataTable $Output[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $GpoSettings
}
}
} else {
New-HTMLTable -DataTable $Output[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $Key
New-HTMLTable -DataTable $Output[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $GpoSettings
}
}
}
Expand Down
35 changes: 35 additions & 0 deletions Private/ConvertTo-Audit.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function ConvertTo-Audit {
[cmdletBinding()]
param(
[Array] $GPOList
)
foreach ($GPOEntry in $GPOList) {
$SuccessAttempts = try { [bool]::Parse($GPOEntry.SuccessAttempts) } catch { $null };
$FailureAttempts = try { [bool]::Parse($GPOEntry.FailureAttempts) } catch { $null };
if ($SuccessAttempts -and $FailureAttempts) {
$Setting = 'Success, Failure'
} elseif ($SuccessAttempts) {
$Setting = 'Success'
} elseif ($FailureAttempts) {
$Setting = 'Failure'
} else {
$Setting = 'No auditing'
}
$CreateGPO = [ordered]@{
DisplayName = $GPOEntry.DisplayName #: WO_SEC_NTLM_Auth_Level
DomainName = $GPOEntry.DomainName #: area1.local
GUID = $GPOEntry.GUID #: 364B095E-C7BF-4CC1-9BFA-393BD38975E5
GpoType = $GPOEntry.GpoType #: Computer
GpoCategory = $GPOEntry.GpoCategory #: SecuritySettings
GpoSettings = $GPOEntry.GpoSettings #: SecurityOptions
Policy = $GPOEntry.Name
Setting = $Setting
SuccessAttempts = $SuccessAttempts
FailureAttempts = $FailureAttempts
}
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
37 changes: 37 additions & 0 deletions Private/ConvertTo-AuditAlternative.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function ConvertTo-AuditAlternative {
[cmdletBinding()]
param(
[Array] $GPOList
)
foreach ($GPOEntry in $GPOList) {
$SuccessAttempts = try { [bool]::Parse($GPOEntry.SuccessAttempts) } catch { $null };
$FailureAttempts = try { [bool]::Parse($GPOEntry.FailureAttempts) } catch { $null };
if ($SuccessAttempts -and $FailureAttempts) {
$Setting = 'Success, Failure'
} elseif ($SuccessAttempts) {
$Setting = 'Success'
} elseif ($FailureAttempts) {
$Setting = 'Failure'
} else {
$Setting = 'No auditing'
}
$CreateGPO = [ordered]@{
DisplayName = $GPOEntry.DisplayName #: WO_SEC_NTLM_Auth_Level
DomainName = $GPOEntry.DomainName #: area1.local
GUID = $GPOEntry.GUID #: 364B095E-C7BF-4CC1-9BFA-393BD38975E5
GpoType = $GPOEntry.GpoType #: Computer
GpoCategory = $GPOEntry.GpoCategory #: SecuritySettings
GpoSettings = $GPOEntry.GpoSettings #: SecurityOptions
Policy = $GPOEntry.Name
Setting = $Setting
#SuccessAttempts = $SuccessAttempts
#FailureAttempts = $FailureAttempts
}


$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
51 changes: 32 additions & 19 deletions Private/Get-XMLStandard.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,39 @@
foreach ($GpoType in @('User', 'Computer')) {
if ($GPOOutput.$GpoType.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$GpoType.ExtensionData.Extension) {
$GPOSettingTypeSplit = ($ExtensionType.type -split ':')
$KeysToLoop = $ExtensionType | Get-Member -MemberType Properties | Where-Object { $_.Name -notin 'type', $GPOSettingTypeSplit[0] }
foreach ($GpoSettings in $KeysToLoop.Name) {
foreach ($Key in $ExtensionType.$GpoSettings) {
$Template = [ordered] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
GpoType = $GpoType
GpoCategory = $GPOSettingTypeSplit[1]
GpoSettings = $GpoSettings
}
$Properties = ($Key | Get-Member -MemberType Properties).Name
foreach ($Property in $Properties) {
$Template["$Property"] = $Key.$Property
# It's possible that one of the ExtensionType records has value null. Weird but happend.
if ($ExtensionType) {
$GPOSettingTypeSplit = ($ExtensionType.type -split ':')
try {
$KeysToLoop = $ExtensionType | Get-Member -MemberType Properties -ErrorAction Stop | Where-Object { $_.Name -notin 'type', $GPOSettingTypeSplit[0] }
} catch {
Write-Warning "Get-XMLStandard - things went sideways $($_.Exception.Message)"
continue
}
foreach ($GpoSettings in $KeysToLoop.Name) {
foreach ($Key in $ExtensionType.$GpoSettings) {
$Template = [ordered] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
GpoType = $GpoType
GpoCategory = $GPOSettingTypeSplit[1]
GpoSettings = $GpoSettings
}
try {
$Properties = ($Key | Get-Member -MemberType Properties -ErrorAction Stop).Name
} catch {
Write-Warning "Get-XMLStandard - things went sideways 1 $($_.Exception.Message)"
$Properties = $null
}
foreach ($Property in $Properties) {
$Template["$Property"] = $Key.$Property
}
$Template['Linked'] = $LinksInformation.Linked
$Template['LinksCount'] = $LinksInformation.LinksCount
$Template['Links'] = $LinksInformation.Links
[PSCustomObject] $Template
}
$Template['Linked'] = $LinksInformation.Linked
$Template['LinksCount'] = $LinksInformation.LinksCount
$Template['Links'] = $LinksInformation.Links
[PSCustomObject] $Template
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions Private/Script.GPODictionary.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@
ConvertTo-AccountPolicies -GPOList $GPOList
}
}
Audit = [ordered] @{
Category = 'SecuritySettings'
Settings = 'Audit'
#GPOPath = 'Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Account Policies'
Code = {
ConvertTo-Audit -GPOList $GPOList
}
}
AuditAlternative = [ordered] @{
Category = 'SecuritySettings'
Settings = 'Audit'
#GPOPath = 'Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Account Policies'
Code = {
ConvertTo-AuditAlternative -GPOList $GPOList
}
}
Autologon = [ordered] @{
Category = 'RegistrySettings'
Settings = 'RegistrySettings'
Expand Down
Loading

0 comments on commit 9e837d2

Please sign in to comment.