diff --git a/Private/ConvertTo-XMLPrinters.ps1 b/Private/ConvertTo-XMLPrinters.ps1 index 42ffe48..4ef51ed 100644 --- a/Private/ConvertTo-XMLPrinters.ps1 +++ b/Private/ConvertTo-XMLPrinters.ps1 @@ -15,42 +15,20 @@ function ConvertTo-XMLPrinters { Count = 0 Settings = $null } - [Array] $CreateGPO['Settings'] = foreach ($Type in @('SharedPrinter', 'PortPrinter', 'LocalPrinter')) { - foreach ($Entry in $GPO.DataSet.$Type) { - [PSCustomObject] @{ - Changed = [DateTime] $Entry.changed - #uid = $Entry.uid - BypassErrors = if ($Entry.bypassErrors -eq '1') { $true } elseif ($Entry.bypassErrors -eq '0') { $false } else { $Entry.bypassErrors }; - GPOSettingOrder = $Entry.GPOSettingOrder - Filter = $Entry.Filter - Type = $Type - Action = $Script:Actions["$($Entry.Properties.action)"] - Comment = $Entry.Properties.comment - Path = $Entry.Properties.path - Location = $Entry.Properties.location - - HostName = $Entry.Properties.ipAddress #: 10.42.20.204 - LocalName = $Entry.Properties.localName #: CZ02PRT00017 - UseDNS = if ($Entry.Properties.useDNS -eq '1') { $true } elseif ($Entry.Properties.useDNS -eq '0') { $false } else { $Entry.Properties.useDNS }; - UseIPv6 = if ($Entry.Properties.useIPv6 -eq '1') { $true } elseif ($Entry.Properties.useIPv6 -eq '0') { $false } else { $Entry.Properties.useIPv6 }; - Default = if ($Entry.Properties.default -eq '1') { $true } elseif ($Entry.Properties.default -eq '0') { $false } else { $Entry.Properties.default }; - SkipLocal = if ($Entry.Properties.skipLocal -eq '1') { $true } elseif ($Entry.Properties.skipLocal -eq '0') { $false } else { $Entry.Properties.skipLocal }; - DeleteAllShared = if ($Entry.Properties.deleteAll -eq '1') { $true } elseif ($Entry.Properties.deleteAll -eq '0') { $false } else { $Entry.Properties.deleteAll }; - Persistent = if ($Entry.Properties.persistent -eq '1') { $true } elseif ($Entry.Properties.persistent -eq '0') { $false } else { $Entry.Properties.persistent }; - DeleteMaps = if ($Entry.Properties.deleteMaps -eq '1') { $true } elseif ($Entry.Properties.deleteMaps -eq '0') { $false } else { $Entry.Properties.deleteMaps }; - LPRSettingsQueueName = $Entry.Properties.lprQueue #: - - Protocol = $Entry.Properties.protocol #: PROTOCOL_RAWTCP_TYPE - PortNumber = if ($Entry.Properties.portNumber) { $Entry.Properties.portNumber } else { $Entry.Properties.port } - DoubleSpool = if ($Entry.Properties.doubleSpool -eq '1') { $true } elseif ($Entry.Properties.doubleSpool -eq '0') { $false } else { $Entry.Properties.doubleSpool }; - - SNMPEnabled = if ($Entry.Properties.snmpEnabled -eq '1') { $true } elseif ($Entry.Properties.snmpEnabled -eq '0') { $false } else { $Entry.Properties.snmpEnabled }; - SNMPCommunityName = $Entry.Properties.snmpCommunity #: public - SNMPDeviceIndex = $Entry.Properties.snmpDevIndex #: 1 - + [Array] $CreateGPO['Settings'] = @( + foreach ($Type in @('SharedPrinter', 'PortPrinter', 'LocalPrinter')) { + foreach ($Entry in $GPO.DataSet.$Type) { + if ($Entry) { + ConvertTo-XMLPrinterInternal -GPO $GPO -Entry $Entry -Type $Type -Limited + } } } - } + if ($GPO.GpoCategory -eq 'PrinterConnectionSettings') { + foreach ($Entry in $GPO.DataSet) { + ConvertTo-XMLPrinterInternal -GPO $GPO -Entry $Entry -Type 'PrinterConnections' -Limited + } + } + ) $CreateGPO['Count'] = $CreateGPO['Settings'].Count $CreateGPO['Linked'] = $GPO.Linked $CreateGPO['LinksCount'] = $GPO.LinksCount @@ -59,49 +37,111 @@ function ConvertTo-XMLPrinters { } else { foreach ($Type in @('SharedPrinter', 'PortPrinter', 'LocalPrinter')) { foreach ($Entry in $GPO.DataSet.$Type) { - $CreateGPO = [ordered]@{ - DisplayName = $GPO.DisplayName - DomainName = $GPO.DomainName - GUID = $GPO.GUID - GpoType = $GPO.GpoType - #GpoCategory = $GPOEntry.GpoCategory - #GpoSettings = $GPOEntry.GpoSettings - Changed = [DateTime] $Entry.changed - #uid = $Entry.uid - BypassErrors = if ($Entry.bypassErrors -eq '1') { $true } elseif ($Entry.bypassErrors -eq '0') { $false } else { $Entry.bypassErrors }; - GPOSettingOrder = $Entry.GPOSettingOrder - Filter = $Entry.Filter - Type = $Type - Action = $Script:Actions["$($Entry.Properties.action)"] - Comment = $Entry.Properties.comment - Path = $Entry.Properties.path - Location = $Entry.Properties.location - - HostName = $Entry.Properties.ipAddress #: 10.42.20.204 - LocalName = $Entry.Properties.localName #: CZ02PRT00017 - UseDNS = if ($Entry.Properties.useDNS -eq '1') { $true } elseif ($Entry.Properties.useDNS -eq '0') { $false } else { $Entry.Properties.useDNS }; - UseIPv6 = if ($Entry.Properties.useIPv6 -eq '1') { $true } elseif ($Entry.Properties.useIPv6 -eq '0') { $false } else { $Entry.Properties.useIPv6 }; - Default = if ($Entry.Properties.default -eq '1') { $true } elseif ($Entry.Properties.default -eq '0') { $false } else { $Entry.Properties.default }; - SkipLocal = if ($Entry.Properties.skipLocal -eq '1') { $true } elseif ($Entry.Properties.skipLocal -eq '0') { $false } else { $Entry.Properties.skipLocal }; - DeleteAllShared = if ($Entry.Properties.deleteAll -eq '1') { $true } elseif ($Entry.Properties.deleteAll -eq '0') { $false } else { $Entry.Properties.deleteAll }; - Persistent = if ($Entry.Properties.persistent -eq '1') { $true } elseif ($Entry.Properties.persistent -eq '0') { $false } else { $Entry.Properties.persistent }; - DeleteMaps = if ($Entry.Properties.deleteMaps -eq '1') { $true } elseif ($Entry.Properties.deleteMaps -eq '0') { $false } else { $Entry.Properties.deleteMaps }; - LPRSettingsQueueName = $Entry.Properties.lprQueue #: - - Protocol = $Entry.Properties.protocol #: PROTOCOL_RAWTCP_TYPE - PortNumber = if ($Entry.Properties.portNumber) { $Entry.Properties.portNumber } else { $Entry.Properties.port } - DoubleSpool = if ($Entry.Properties.doubleSpool -eq '1') { $true } elseif ($Entry.Properties.doubleSpool -eq '0') { $false } else { $Entry.Properties.doubleSpool }; - - SNMPEnabled = if ($Entry.Properties.snmpEnabled -eq '1') { $true } elseif ($Entry.Properties.snmpEnabled -eq '0') { $false } else { $Entry.Properties.snmpEnabled }; - SNMPCommunityName = $Entry.Properties.snmpCommunity #: public - SNMPDeviceIndex = $Entry.Properties.snmpDevIndex #: 1 - + if ($Entry) { + ConvertTo-XMLPrinterInternal -GPO $GPO -Entry $Entry -Type $Type } - $CreateGPO['Linked'] = $GPO.Linked - $CreateGPO['LinksCount'] = $GPO.LinksCount - $CreateGPO['Links'] = $GPO.Links - [PSCustomObject] $CreateGPO + } + } + if ($GPO.GpoCategory -eq 'PrinterConnectionSettings') { + foreach ($Entry in $GPO.DataSet) { + ConvertTo-XMLPrinterInternal -GPO $GPO -Entry $Entry -Type 'PrinterConnections' } } } +} + +function ConvertTo-XMLPrinterInternal { + [cmdletBinding()] + param( + [PSCustomObject] $GPO, + $Entry, + $Type, + [switch] $Limited + ) + if ($Limited) { + $CreateGPO = [ordered]@{ + Changed = try { [DateTime] $Entry.changed } catch { $Entry.Changed }; + #uid = $Entry.uid + BypassErrors = if ($Entry.bypassErrors -eq '1') { $true } elseif ($Entry.bypassErrors -eq '0') { $false } else { $Entry.bypassErrors }; + GPOSettingOrder = $Entry.GPOSettingOrder + Filter = $Entry.Filter + type = $Type + Action = $null #$Script:Actions["$($Entry.Properties.action)"] + Comment = $Entry.Properties.comment + Path = if ($Entry.Properties.path) { $Entry.Properties.Path } elseif ($Entry.Path) { $Entry.Path } else { '' } + Location = $Entry.Properties.location + + HostName = $Entry.Properties.ipAddress #: 10.42.20.204 + LocalName = $Entry.Properties.localName #: CZ02PRT00017 + UseDNS = if ($Entry.Properties.useDNS -eq '1') { $true } elseif ($Entry.Properties.useDNS -eq '0') { $false } else { $Entry.Properties.useDNS }; + UseIPv6 = if ($Entry.Properties.useIPv6 -eq '1') { $true } elseif ($Entry.Properties.useIPv6 -eq '0') { $false } else { $Entry.Properties.useIPv6 }; + Default = if ($Entry.Properties.default -eq '1') { $true } elseif ($Entry.Properties.default -eq '0') { $false } else { $Entry.Properties.default }; + SkipLocal = if ($Entry.Properties.skipLocal -eq '1') { $true } elseif ($Entry.Properties.skipLocal -eq '0') { $false } else { $Entry.Properties.skipLocal }; + DeleteAllShared = if ($Entry.Properties.deleteAll -eq '1') { $true } elseif ($Entry.Properties.deleteAll -eq '0') { $false } else { $Entry.Properties.deleteAll }; + Persistent = if ($Entry.Properties.persistent -eq '1') { $true } elseif ($Entry.Properties.persistent -eq '0') { $false } else { $Entry.Properties.persistent }; + DeleteMaps = if ($Entry.Properties.deleteMaps -eq '1') { $true } elseif ($Entry.Properties.deleteMaps -eq '0') { $false } else { $Entry.Properties.deleteMaps }; + LPRSettingsQueueName = $Entry.Properties.lprQueue #: + + Protocol = $Entry.Properties.protocol #: PROTOCOL_RAWTCP_TYPE + PortNumber = if ($Entry.Properties.portNumber) { $Entry.Properties.portNumber } else { $Entry.Properties.port } + DoubleSpool = if ($Entry.Properties.doubleSpool -eq '1') { $true } elseif ($Entry.Properties.doubleSpool -eq '0') { $false } else { $Entry.Properties.doubleSpool }; + + SNMPEnabled = if ($Entry.Properties.snmpEnabled -eq '1') { $true } elseif ($Entry.Properties.snmpEnabled -eq '0') { $false } else { $Entry.Properties.snmpEnabled }; + SNMPCommunityName = $Entry.Properties.snmpCommunity #: public + SNMPDeviceIndex = $Entry.Properties.snmpDevIndex #: 1 + } + if ($Entry.Properties.Action) { + $CreateGPO['Action'] = $Script:Actions["$($Entry.Properties.action)"] + } else { + $CreateGPO['Action'] = 'Deploy' + } + [PSCustomObject] $CreateGPO + } else { + $CreateGPO = [ordered]@{ + DisplayName = $GPO.DisplayName + DomainName = $GPO.DomainName + GUID = $GPO.GUID + GpoType = $GPO.GpoType + GpoCategory = $GPO.GpoCategory + GpoSettings = $GPO.GpoSettings + Changed = try { [DateTime] $Entry.changed } catch { $Entry.Changed }; + #uid = $Entry.uid + BypassErrors = if ($Entry.bypassErrors -eq '1') { $true } elseif ($Entry.bypassErrors -eq '0') { $false } else { $Entry.bypassErrors }; + GPOSettingOrder = $Entry.GPOSettingOrder + Filter = $Entry.Filter + type = $Type + Action = $null #$Script:Actions["$($Entry.Properties.action)"] + Comment = $Entry.Properties.comment + Path = if ($Entry.Properties.path) { $Entry.Properties.Path } elseif ($Entry.Path) { $Entry.Path } else { '' } + Location = $Entry.Properties.location + + HostName = $Entry.Properties.ipAddress #: 10.42.20.204 + LocalName = $Entry.Properties.localName #: CZ02PRT00017 + UseDNS = if ($Entry.Properties.useDNS -eq '1') { $true } elseif ($Entry.Properties.useDNS -eq '0') { $false } else { $Entry.Properties.useDNS }; + UseIPv6 = if ($Entry.Properties.useIPv6 -eq '1') { $true } elseif ($Entry.Properties.useIPv6 -eq '0') { $false } else { $Entry.Properties.useIPv6 }; + Default = if ($Entry.Properties.default -eq '1') { $true } elseif ($Entry.Properties.default -eq '0') { $false } else { $Entry.Properties.default }; + SkipLocal = if ($Entry.Properties.skipLocal -eq '1') { $true } elseif ($Entry.Properties.skipLocal -eq '0') { $false } else { $Entry.Properties.skipLocal }; + DeleteAllShared = if ($Entry.Properties.deleteAll -eq '1') { $true } elseif ($Entry.Properties.deleteAll -eq '0') { $false } else { $Entry.Properties.deleteAll }; + Persistent = if ($Entry.Properties.persistent -eq '1') { $true } elseif ($Entry.Properties.persistent -eq '0') { $false } else { $Entry.Properties.persistent }; + DeleteMaps = if ($Entry.Properties.deleteMaps -eq '1') { $true } elseif ($Entry.Properties.deleteMaps -eq '0') { $false } else { $Entry.Properties.deleteMaps }; + LPRSettingsQueueName = $Entry.Properties.lprQueue #: + + Protocol = $Entry.Properties.protocol #: PROTOCOL_RAWTCP_TYPE + PortNumber = if ($Entry.Properties.portNumber) { $Entry.Properties.portNumber } else { $Entry.Properties.port } + DoubleSpool = if ($Entry.Properties.doubleSpool -eq '1') { $true } elseif ($Entry.Properties.doubleSpool -eq '0') { $false } else { $Entry.Properties.doubleSpool }; + + SNMPEnabled = if ($Entry.Properties.snmpEnabled -eq '1') { $true } elseif ($Entry.Properties.snmpEnabled -eq '0') { $false } else { $Entry.Properties.snmpEnabled }; + SNMPCommunityName = $Entry.Properties.snmpCommunity #: public + SNMPDeviceIndex = $Entry.Properties.snmpDevIndex #: 1 + } + if ($Entry.Properties.Action) { + $CreateGPO['Action'] = $Script:Actions["$($Entry.Properties.action)"] + } else { + $CreateGPO['Action'] = 'Deploy' + } + $CreateGPO['Linked'] = $GPO.Linked + $CreateGPO['LinksCount'] = $GPO.LinksCount + $CreateGPO['Links'] = $GPO.Links + [PSCustomObject] $CreateGPO + } } \ No newline at end of file diff --git a/Private/ConvertTo-XMLTaskScheduler.ps1 b/Private/ConvertTo-XMLTaskScheduler.ps1 new file mode 100644 index 0000000..3a32ceb --- /dev/null +++ b/Private/ConvertTo-XMLTaskScheduler.ps1 @@ -0,0 +1,75 @@ +function ConvertTo-XMLTaskScheduler { + [cmdletBinding()] + param( + [PSCustomObject] $GPO, + [switch] $SingleObject + ) + if ($SingleObject) { + $CreateGPO = [ordered]@{ + DisplayName = $GPO.DisplayName + DomainName = $GPO.DomainName + GUID = $GPO.GUID + GpoType = $GPO.GpoType + #GpoCategory = $GPOEntry.GpoCategory + #GpoSettings = $GPOEntry.GpoSettings + Count = 0 + Settings = $null + } + [Array] $CreateGPO['Settings'] = foreach ($Entry in $GPO.DataSet.Drive) { + [PSCustomObject] @{ + Changed = [DateTime] $Entry.changed + #uid = $Entry.uid + GPOSettingOrder = $Entry.GPOSettingOrder + Filter = $Entry.Filter + + Name = $Entry.Name + Status = $Entry.status + Action = $Script:Actions["$($Entry.Properties.action)"] + ThisDrive = $Entry.Properties.thisDrive + AllDrives = $Entry.Properties.allDrives + UserName = $Entry.Properties.userName + Path = $Entry.Properties.path + Label = $Entry.Properties.label + Persistent = if ($Entry.Properties.persistent -eq '1') { $true } elseif ($Entry.Properties.persistent -eq '0') { $false } else { $Entry.Properties.persistent }; + UseLetter = if ($Entry.Properties.useLetter -eq '1') { $true } elseif ($Entry.Properties.useLetter -eq '0') { $false } else { $Entry.Properties.useLetter }; + Letter = $Entry.Properties.letter + } + } + $CreateGPO['Count'] = $CreateGPO['Settings'].Count + $CreateGPO['Linked'] = $GPO.Linked + $CreateGPO['LinksCount'] = $GPO.LinksCount + $CreateGPO['Links'] = $GPO.Links + [PSCustomObject] $CreateGPO + } else { + foreach ($Entry in $GPO.DataSet.Drive) { + $CreateGPO = [ordered]@{ + DisplayName = $GPO.DisplayName + DomainName = $GPO.DomainName + GUID = $GPO.GUID + GpoType = $GPO.GpoType + #GpoCategory = $GPOEntry.GpoCategory + #GpoSettings = $GPOEntry.GpoSettings + Changed = [DateTime] $Entry.changed + #uid = $Entry.uid + GPOSettingOrder = $Entry.GPOSettingOrder + Filter = $Entry.Filter + + Name = $Entry.Name + Status = $Entry.status + Action = $Script:Actions["$($Entry.Properties.action)"] + ThisDrive = $Entry.Properties.thisDrive + AllDrives = $Entry.Properties.allDrives + UserName = $Entry.Properties.userName + Path = $Entry.Properties.path + Label = $Entry.Properties.label + Persistent = if ($Entry.Properties.persistent -eq '1') { $true } elseif ($Entry.Properties.persistent -eq '0') { $false } else { $Entry.Properties.persistent }; + UseLetter = if ($Entry.Properties.useLetter -eq '1') { $true } elseif ($Entry.Properties.useLetter -eq '0') { $false } else { $Entry.Properties.useLetter }; + Letter = $Entry.Properties.letter + } + $CreateGPO['Linked'] = $GPO.Linked + $CreateGPO['LinksCount'] = $GPO.LinksCount + $CreateGPO['Links'] = $GPO.Links + [PSCustomObject] $CreateGPO + } + } +} \ No newline at end of file diff --git a/Private/Script.GPODictionary.ps1 b/Private/Script.GPODictionary.ps1 index 14c70ee..a4b0882 100644 --- a/Private/Script.GPODictionary.ps1 +++ b/Private/Script.GPODictionary.ps1 @@ -1,7 +1,11 @@ $Script:GPODitionary = [ordered] @{ AccountPolicies = [ordered] @{ - Category = 'SecuritySettings' - Settings = 'Account' + Types = @( + @{ + Category = 'SecuritySettings' + Settings = 'Account' + } + ) GPOPath = 'Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Account Policies' Code = { ConvertTo-XMLAccountPolicies -GPO $GPO @@ -11,8 +15,12 @@ } } Audit = [ordered] @{ - Category = 'SecuritySettings' - Settings = 'Audit' + Types = @( + @{ + Category = 'SecuritySettings' + Settings = 'Audit' + } + ) GPOPath = '' Code = { ConvertTo-XMLAudit -GPO $GPO @@ -22,8 +30,12 @@ } } Autologon = [ordered] @{ - Category = 'RegistrySettings' - Settings = 'RegistrySettings' + Types = @( + @{ + Category = 'RegistrySettings' + Settings = 'RegistrySettings' + } + ) Code = { ConvertTo-XMLRegistryAutologon -GPO $GPO } @@ -32,8 +44,12 @@ } } DriveMapping = [ordered] @{ - Category = 'DriveMapSettings' - Settings = 'DriveMapSettings' + Types = @( + @{ + Category = 'DriveMapSettings' + Settings = 'DriveMapSettings' + } + ) GPOPath = '' Code = { ConvertTo-XMLDriveMapSettings -GPO $GPO @@ -43,8 +59,12 @@ } } EventLog = [ordered] @{ - Category = 'SecuritySettings' - Settings = 'EventLog' + Types = @( + @{ + Category = 'SecuritySettings' + Settings = 'EventLog' + } + ) GPOPath = '' Code = { ConvertTo-XMLEventLog -GPO $GPO @@ -54,8 +74,12 @@ } } LocalUsers = [ordered] @{ - Category = 'LugsSettings' - Settings = 'LocalUsersAndGroups' + Types = @( + @{ + Category = 'LugsSettings' + Settings = 'LocalUsersAndGroups' + } + ) Code = { ConvertTo-XMLLocalUser -GPO $GPO } @@ -64,8 +88,12 @@ } } LocalGroups = [ordered] @{ - Category = 'LugsSettings' - Settings = 'LocalUsersAndGroups' + Types = @( + @{ + Category = 'LugsSettings' + Settings = 'LocalUsersAndGroups' + } + ) Code = { ConvertTo-XMLLocalGroups -GPO $GPO } @@ -74,8 +102,12 @@ } } Policies = @{ - Category = 'RegistrySettings' - Settings = 'Policy' + Types = @( + @{ + Category = 'RegistrySettings' + Settings = 'Policy' + } + ) Code = { ConvertTo-XMLPolicies -GPO $GPO } @@ -84,8 +116,16 @@ } } Printers = @{ - Category = 'PrintersSettings' - Settings = 'Printers' + Types = @( + @{ + Category = 'PrintersSettings' + Settings = 'Printers' + } + @{ + Category = 'PrinterConnectionSettings' + Settings = 'PrinterConnection' + } + ) Code = { ConvertTo-XMLPrinters -GPO $GPO } @@ -94,8 +134,12 @@ } } RegistrySettings = [ordered] @{ - Category = 'RegistrySettings' - Settings = 'RegistrySettings' + Types = @( + @{ + Category = 'RegistrySettings' + Settings = 'RegistrySettings' + } + ) Code = { ConvertTo-XMLRegistrySettings -GPO $GPO } @@ -104,8 +148,12 @@ } } Scripts = [ordered] @{ - Category = 'Scripts' - Settings = 'Script' + Types = @( + @{ + Category = 'Scripts' + Settings = 'Script' + } + ) Code = { ConvertTo-XMLScripts -GPO $GPO } @@ -114,8 +162,12 @@ } } SecurityOptions = [ordered] @{ - Category = 'SecuritySettings' - Settings = 'SecurityOptions' + Types = @( + @{ + Category = 'SecuritySettings' + Settings = 'SecurityOptions' + } + ) Code = { ConvertTo-XMLSecurityOptions -GPO $GPO } @@ -124,8 +176,12 @@ } } SoftwareInstallation = [ordered] @{ - Category = 'SoftwareInstallationSettings' - Settings = 'MsiApplication' + Types = @( + @{ + Category = 'SoftwareInstallationSettings' + Settings = 'MsiApplication' + } + ) Code = { ConvertTo-XMLSoftwareInstallation -GPO $GPO } @@ -134,10 +190,14 @@ } } SystemServices = [ordered] @{ + Types = @( + @{ + Category = 'SecuritySettings' + Settings = 'SystemServices' + } + ) Description = '' GPOPath = 'Computer Configuration -> Policies -> Windows Settings -> Security Settings -> System Services' - Category = 'SecuritySettings' - Settings = 'SystemServices' Code = { ConvertTo-XMLSystemServices -GPO $GPO } @@ -146,10 +206,14 @@ } } SystemServicesNT = [ordered] @{ + Types = @( + @{ + Category = 'ServiceSettings' + Settings = 'NTServices' + } + ) Description = '' GPOPath = 'Computer Configuration -> Preferences -> Control Pannel Settings -> Services' - Category = 'ServiceSettings' - Settings = 'NTServices' Code = { ConvertTo-XMLSystemServicesNT -GPO $GPO } @@ -157,4 +221,20 @@ ConvertTo-XMLSystemServicesNT -GPO $GPO -SingleObject } } + TaskScheduler = [ordered] @{ + Types = @( + @{ + Category = 'ScheduledTasksSettings' + Settings = 'ScheduledTasks' + } + ) + Description = '' + GPOPath = '' + Code = { + ConvertTo-XMLTaskScheduler -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLTaskScheduler -GPO $GPO -SingleObject + } + } } \ No newline at end of file diff --git a/Public/Invoke-GPOZaurr.ps1 b/Public/Invoke-GPOZaurr.ps1 index c96f48f..ff419b7 100644 --- a/Public/Invoke-GPOZaurr.ps1 +++ b/Public/Invoke-GPOZaurr.ps1 @@ -108,34 +108,38 @@ if ($CachedCategories.Count -gt 0) { foreach ($Report in $Type) { - $Category = $Script:GPODitionary[$Report]['Category'] - $Settings = $Script:GPODitionary[$Report]['Settings'] - # Those are checks for making sure we have data to be even able to process it - if (-not $CachedCategories[$Category]) { - continue - } - if (-not $CachedCategories[$Category][$Settings]) { - continue - } - # Translation - $CategorizedGPO = $CachedCategories[$Category][$Settings] - foreach ($GPO in $CategorizedGPO) { - if (-not $Output['Reports'][$Report]) { - $Output['Reports'][$Report] = [System.Collections.Generic.List[PSCustomObject]]::new() + foreach ($CategoryType in $Script:GPODitionary[$Report].Types) { + + $Category = $CategoryType.Category + $Settings = $CategoryType.Settings + + # Those are checks for making sure we have data to be even able to process it + if (-not $CachedCategories[$Category]) { + continue } - $TranslatedGpo = $null - if ($SingleObject) { - if ($Script:GPODitionary[$Report]['CodeSingle']) { - $TranslatedGpo = Invoke-Command -ScriptBlock $Script:GPODitionary[$Report]['CodeSingle'] - } - } else { - if ($Script:GPODitionary[$Report]['Code']) { - $TranslatedGpo = Invoke-Command -ScriptBlock $Script:GPODitionary[$Report]['Code'] - } + if (-not $CachedCategories[$Category][$Settings]) { + continue } - foreach ($T in $TranslatedGpo) { - $Output['Reports'][$Report].Add($T) + # Translation + $CategorizedGPO = $CachedCategories[$Category][$Settings] + foreach ($GPO in $CategorizedGPO) { + if (-not $Output['Reports'][$Report]) { + $Output['Reports'][$Report] = [System.Collections.Generic.List[PSCustomObject]]::new() + } + $TranslatedGpo = $null + if ($SingleObject) { + if ($Script:GPODitionary[$Report]['CodeSingle']) { + $TranslatedGpo = Invoke-Command -ScriptBlock $Script:GPODitionary[$Report]['CodeSingle'] + } + } else { + if ($Script:GPODitionary[$Report]['Code']) { + $TranslatedGpo = Invoke-Command -ScriptBlock $Script:GPODitionary[$Report]['Code'] + } + } + foreach ($T in $TranslatedGpo) { + $Output['Reports'][$Report].Add($T) + } } } }