This commit is contained in:
Przemyslaw Klys
2020-06-28 15:47:37 +02:00
parent 2f25064090
commit e76c4d9094
9 changed files with 258 additions and 34 deletions
@@ -0,0 +1,22 @@
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 | Format-Table *
New-HTML {
foreach ($GPOCategory in $OutputNoTranslation.Keys) {
New-HTMLTab -Name $GPOCategory {
if ($Output["$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
}
}
} else {
New-HTMLTable -DataTable $OutputNoTranslation[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $Key
}
}
}
} -Online -ShowHTML -FilePath $Env:UserProfile\Desktop\OutputFromFindGPO-NoTranslationFromDisk.html
@@ -2,7 +2,7 @@
# Use Save-GPOZaurrFiles -GPOPath $ENV:USERPROFILE\Desktop\GPOExport
$Output = Invoke-GPOZaurr -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExportTest' #-NoTranslation
$Output = Invoke-GPOZaurr -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExportTest'
$Output | Format-Table *
New-HTML {
@@ -19,4 +19,4 @@ New-HTML {
}
}
}
} -Online -ShowHTML -FilePath $Env:UserProfile\Desktop\OutputFromFindGPO.html
} -Online -ShowHTML -FilePath $Env:UserProfile\Desktop\OutputFromFindGPO-FromDisk.html
@@ -0,0 +1,19 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
$Output = Invoke-GPOZaurr -NoTranslation
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
}
}
} else {
New-HTMLTable -DataTable $Output[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $Key
}
}
}
} -Online -ShowHTML -FilePath $Env:UserProfile\Desktop\OutputFromFindGPO-NoTranslation.html
+7 -3
View File
@@ -5,10 +5,14 @@ $Output = Invoke-GPOZaurr #-NoTranslation
New-HTML {
foreach ($GPOCategory in $Output.Keys) {
New-HTMLTab -Name $GPOCategory {
foreach ($GpoSettings in $Output.$GPOCategory.Keys) {
New-HTMLTab -Name $GpoSettings {
New-HTMLTable -DataTable $Output[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $Key
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
}
}
} else {
New-HTMLTable -DataTable $Output[$GPOCategory] -ScrollX -DisablePaging -AllProperties -Title $Key
}
}
}
+15
View File
@@ -0,0 +1,15 @@
function Find-MissingProperties {
[cmdletBinding()]
param(
[Array] $Objects,
[string[]] $PossibleProperties
)
$AllProperties = Select-Properties -AllProperties -Objects $Objects
$MissingProperties = $AllProperties | Where-Object { $_ -notin 'DisplayName', 'DomainName', 'GUID', 'Linked', 'LinksCount', 'Links', 'GPOType', 'GPOCategory', 'GPOSettings' }
[Array] $ConsiderAdding = foreach ($Property in $MissingProperties) {
if ($Property -notin $PossibleProperties) {
$Property
}
}
$ConsiderAdding
}
+76
View File
@@ -0,0 +1,76 @@
$RegistrySettings = [ordered] @{
Category = 'RegistrySettings'
Settings = 'RegistrySettings'
# This is to make sure we're not loosing anything
# We will detect this and if something is missing provide details
PossibleProperties = @(
'clsid', 'Registry', 'Collection'
)
LoopOver = [ordered] @{
Registry = @{
'Hive' = 'Properties', 'Hive'
'Key' = 'Properties', 'Key'
'Name' = 'Properties', 'Name'
'Type' = 'Properties', 'Type'
'action' = 'Properties', 'action'
'displayDecimal' = 'Properties', 'displayDecimal'
'default' = 'Properties', 'default'
'Value' = 'Properties', 'Value'
'Changed' = 'Changed'
'GPOSettingOrder' = 'GPOSettingOrder'
'Filters' = 'Filters'
}
}
Translate = [ordered] @{
}
Types = [ordered] @{
'Changed' = { try { [datetime]::Parse($args) } catch { $null } }
}
}
function Set-SpecialObject {
[cmdletbInding()]
param(
$GPOEntry,
$DataDictionaryLoop,
$DataDictionary,
$DataObject,
$Key = 'Translate'
)
$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
}
foreach ($PropertyName in $DataDictionaryLoop.Keys) {
# We get property that we expect on our $GPOEntry object
$Property = $DataDictionaryLoop[$Key][$PropertyName]
# Since it's possible we may be interested in something that is a nested property we need to do some looping into the object
$Value = $DataObject
foreach ($P in $Property) {
$Value = $Value.$P
}
# Now we simply assing that value to new GPO Entry
# But before we do so, we need to check if it has required type
if ($DataDictionary[$Report]['Types'][$PropertyName]) {
# This basically checks in dictionary if we want to convert the type from a string to lets say boolean or something else
$CreateGPO["$PropertyName"] = Invoke-Command -Command $DataDictionary[$Report]['Types'][$PropertyName] -ArgumentList $Value
} else {
$CreateGPO["$PropertyName"] = $Value
}
}
# return GPO Entry
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
@@ -0,0 +1,33 @@
$RegistrySettingsCollection = [ordered] @{
Category = 'RegistrySettings'
Settings = 'RegistrySettings'
# This is to make sure we're not loosing anything
# We will detect this and if something is missing provide details
PossibleProperties = @(
'clsid', 'Registry', 'Collection'
)
LoopOver = [ordered] @{
Collection = [ordered] @{
'Changed' = 'Changed'
'GPOSettingOrder' = 'GPOSettingOrder'
'Filters' = 'Filters'
'BypassErrors' = 'bypassErrors'
Registry = [ordered] @{
'Hive' = 'Properties', 'Hive'
'Key' = 'Properties', 'Key'
'Name' = 'Properties', 'Name'
'Type' = 'Properties', 'Type'
'action' = 'Properties', 'action'
'displayDecimal' = 'Properties', 'displayDecimal'
'default' = 'Properties', 'default'
'Value' = 'Properties', 'Value'
}
}
}
Translate = [ordered] @{
}
Types = [ordered] @{
'Changed' = { try { [datetime]::Parse($args) } catch { $null } }
}
}
+81 -28
View File
@@ -13,6 +13,7 @@
}
# This section basically makes sure we check for all properties in GPO Types.
# It's possible given small input of GPOs that I work with that this is not all... and needs updates
<#
$AllProperties = Select-Properties -AllProperties -Objects $InputData.$Category.$Settings
$MissingProperties = $AllProperties | Where-Object { $_ -notin 'DisplayName', 'DomainName', 'GUID', 'Linked', 'LinksCount', 'Links', 'GPOType', 'GPOCategory', 'GPOSettings' }
[Array] $ConsiderAdding = foreach ($Property in $MissingProperties) {
@@ -20,6 +21,8 @@
$Property
}
}
#>
$ConsiderAdding = Find-MissingProperties -Objects $InputData.$Category.$Settings -PossibleProperties $Script:GPODitionary[$Report]['PossibleProperties']
if ($ConsiderAdding.Count -gt 0) {
Write-Warning "Invoke-Translation - We're missing property for $Category / $Settings - ($($ConsiderAdding -join ','))"
}
@@ -27,38 +30,88 @@
# Dictionary will need a lot of work and engine some improvements
foreach ($GPOEntry in $InputData.$Category.$Settings) {
# Create new GPO Entry with minimal required properties
$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
}
if ($Script:GPODitionary[$Report]['LoopOver'].Keys) {
foreach ($Key in $Script:GPODitionary[$Report]['LoopOver'].Keys) {
foreach ($DataObject in $GPOEntry.$Key) {
#Set-SpecialObject -GPOEntry $GPOEntry -DataDictionaryLoop $Script:GPODitionary[$Report]['LoopOver'][$Key] -DataDictionary $Script:GPODitionary[$Report] -DataObject $DataObject -Key $Key
# Lets loop thru each Translate Property
foreach ($PropertyName in $Script:GPODitionary[$Report]['Translate'].Keys) {
# We get property that we expect on our $GPOEntry object
$Property = $Script:GPODitionary[$Report]['Translate'][$PropertyName]
#$Script:GPODitionary[$Report]['LoopOver'][$Key].GetEnumerator() | Where-Object { $_.Value -is [System.Collections.IDictionary] }
# Since it's possible we may be interested in something that is a nested property we need to do some looping into the object
$Value = $GPOEntry
foreach ($P in $Property) {
$Value = $Value.$P
$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
}
foreach ($PropertyName in $Script:GPODitionary[$Report]['LoopOver'][$Key].Keys) {
# We get property that we expect on our $GPOEntry object
$Property = $Script:GPODitionary[$Report]['LoopOver'][$Key][$PropertyName]
# Since it's possible we may be interested in something that is a nested property we need to do some looping into the object
$Value = $DataObject
foreach ($P in $Property) {
$Value = $Value.$P
}
# Now we simply assing that value to new GPO Entry
# But before we do so, we need to check if it has required type
if ($Script:GPODitionary[$Report]['Types'][$PropertyName]) {
# This basically checks in dictionary if we want to convert the type from a string to lets say boolean or something else
$CreateGPO["$PropertyName"] = Invoke-Command -Command $Script:GPODitionary[$Report]['Types'][$PropertyName] -ArgumentList $Value
} else {
$CreateGPO["$PropertyName"] = $Value
}
}
# return GPO Entry
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
# Now we simply assing that value to new GPO Entry
# But before we do so, we need to check if it has required type
if ($Script:GPODitionary[$Report]['Types'][$PropertyName]) {
# This basically checks in dictionary if we want to convert the type from a string to lets say boolean or something else
$CreateGPO["$PropertyName"] = Invoke-Command -Command $Script:GPODitionary[$Report]['Types'][$PropertyName] -ArgumentList $Value
} else {
$CreateGPO["$PropertyName"] = $Value
} else {
#Set-SpecialObject -GPOEntry $GPOEntry -DataDictionaryLoop $Script:GPODitionary[$Report]['Translate'] -DataDictionary $Script:GPODitionary[$Report] -DataObject $GPOEntry
$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
}
# Lets loop thru each Translate Property
foreach ($PropertyName in $Script:GPODitionary[$Report]['Translate'].Keys) {
# We get property that we expect on our $GPOEntry object
$Property = $Script:GPODitionary[$Report]['Translate'][$PropertyName]
# Since it's possible we may be interested in something that is a nested property we need to do some looping into the object
$Value = $GPOEntry
foreach ($P in $Property) {
$Value = $Value.$P
}
# Now we simply assing that value to new GPO Entry
# But before we do so, we need to check if it has required type
if ($Script:GPODitionary[$Report]['Types'][$PropertyName]) {
# This basically checks in dictionary if we want to convert the type from a string to lets say boolean or something else
$CreateGPO["$PropertyName"] = Invoke-Command -Command $Script:GPODitionary[$Report]['Types'][$PropertyName] -ArgumentList $Value
} else {
$CreateGPO["$PropertyName"] = $Value
}
}
# return GPO Entry
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
# return GPO Entry
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
+3 -1
View File
@@ -1,5 +1,7 @@
$Script:GPODitionary = @{
SecurityOptions = $SecurityOptions
SecurityOptions = $SecurityOptions
RegistrySettings = $RegistrySettings
RegistrySettingsCollection = $RegistrySettingsCollection
#LugsSettings = @{
# LocalUsersAndGroups = $LugsSettingsLocalUsersAndGroups