Invoke-GPOZaurr WIP

This commit is contained in:
Przemyslaw Klys
2020-06-28 18:42:06 +02:00
parent e76c4d9094
commit 7501693276
23 changed files with 268 additions and 782 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
Save-GPOZaurrFiles -GPOPath $ENV:USERPROFILE\Desktop\GPOExport
#Save-GPOZaurrFiles -GPOPath $ENV:USERPROFILE\Desktop\GPOExport -DeleteExisting
Save-GPOZaurrFiles -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExport' #-DeleteExisting
+1 -1
View File
@@ -2,7 +2,7 @@
# Use Save-GPOZaurrFiles -GPOPath $ENV:USERPROFILE\Desktop\GPOExport
$Output = Invoke-GPOZaurr -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExportTest'
$Output = Invoke-GPOZaurr -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExportTest' # -NoTranslation
$Output | Format-Table *
New-HTML {
+51
View File
@@ -0,0 +1,51 @@
function ConvertTo-RegistryAutologon {
[cmdletBinding()]
param(
[Array] $GPOList
)
foreach ($GPOEntry in $GPOList) {
$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
#Changed = [DateTime] $Registry.changed
GPOSettingOrder = $Registry.GPOSettingOrder
AutoAdminLogon = $null
DefaultDomainName = $null
DefaultUserName = $null
DefaultPassword = $null
}
foreach ($Registry in $GPOEntry.Registry) {
if ($Registry.Properties.Key -eq 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon') {
if ($Registry.Properties.Name -eq 'AutoAdminLogon') {
$CreateGPO['AutoAdminLogon'] = [bool] $Registry.Properties.value
$CreateGPO['DateChangedAutoAdminLogon'] = [DateTime] $Registry.changed
} elseif ($Registry.Properties.Name -eq 'DefaultDomainName') {
$CreateGPO['DefaultDomainName'] = $Registry.Properties.value
$CreateGPO['DateChangedDefaultDomainName'] = [DateTime] $Registry.changed
} elseif ($Registry.Properties.Name -eq 'DefaultUserName') {
$CreateGPO['DefaultUserName'] = $Registry.Properties.value
$CreateGPO['DateChangedDefaultUserName'] = [DateTime] $Registry.changed
} elseif ($Registry.Properties.Name -eq 'DefaultPassword') {
$CreateGPO['DefaultPassword'] = $Registry.Properties.value
$CreateGPO['DateChangedDefaultPassword'] = [DateTime] $Registry.changed
}
}
}
if ($null -ne $CreateGPO['AutoAdminLogon'] -or
$null -ne $CreateGPO['DefaultDomainName'] -or
$null -ne $CreateGPO['DefaultUserName'] -or
$null -ne $CreateGPO['DefaultPassword']
) {
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
}
+30
View File
@@ -0,0 +1,30 @@
function ConvertTo-RegistrySettings {
[cmdletBinding()]
param(
[Array] $GPOList
)
foreach ($GPOEntry in $GPOList) {
foreach ($Registry in $GPOEntry.Registry) {
$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
Changed = [DateTime] $Registry.changed
GPOSettingOrder = $Registry.GPOSettingOrder
Hive = $Registry.Properties.hive #: HKEY_LOCAL_MACHINE
Key = $Registry.Properties.key #: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Name = $Registry.Properties.name #: AutoAdminLogon
Type = $Registry.Properties.type #: REG_SZ
Value = $Registry.Properties.value #
Filters = $Registry.Filters
}
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
}
@@ -0,0 +1,46 @@
function ConvertTo-RegistrySettingsCollection {
[cmdletBinding()]
param(
[Array] $GPOList
)
foreach ($GPOEntry in $GPOList) {
foreach ($Collection in $GPOEntry.Collection) {
$OutputDictionaries = foreach ($Registry in $Collection.Registry) {
[ordered] @{
#"$($Registry.Name)FieldName" = $Registry.Name
#"$($Registry.Name)FieldStatus" = $Registry.Status
"$($Registry.Name)BypassErrors" = try { [bool]::Parse($Registry.BypassErrors) } catch { $null };
"$($Registry.Name)Changed" = [DateTime] $Registry.Changed
"$($Registry.Name)UID" = $Registry.UID
"$($Registry.Name)GPOSettingOrder" = $Registry.GPOSettingOrder
"$($Registry.Name)Action" = $Registry.Properties.action
"$($Registry.Name)DisplayDecimal" = $Registry.Properties.displayDecimal
"$($Registry.Name)Default" = $Registry.Properties.default
"$($Registry.Name)Hive" = $Registry.Properties.hive
"$($Registry.Name)Name" = $Registry.Properties.name
"$($Registry.Name)Type" = $Registry.Properties.type
"$($Registry.Name)Value" = $Registry.Properties.value
"$($Registry.Name)Values" = $Registry.Properties.Values
}
}
$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 ($Dictionary in $OutputDictionaries) {
$CreateGPO = $CreateGPO + $Dictionary
}
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
}
+28
View File
@@ -0,0 +1,28 @@
function ConvertTo-SecurityOptions {
[cmdletBinding()]
param(
[Array] $GPOList
)
foreach ($GPOEntry in $GPOList) {
$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
KeyName = $GPOEntry.KeyName
KeyDisplayName = $GPOEntry.Display.Name
KeyDisplayUnits = $GPOEntry.Display.Units
KeyDisplayBoolean = try { [bool]::Parse($GPOEntry.Display.DisplayBoolean) } catch { $null };
KeyDisplayString = $GPOEntry.Display.DisplayString
SystemAccessPolicyName = $GPOEntry.SystemAccessPolicyName
SettingString = $GPOEntry.SettingString
SettingNumber = $GPOEntry.SettingNumber
}
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
+25
View File
@@ -0,0 +1,25 @@
function ConvertTo-SystemServices {
[cmdletBinding()]
param(
[Array] $GPOList
)
foreach ($GPOEntry in $GPOList) {
$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
ServiceName = $GPOEntry.Name
ServiceStartUpMode = $GPOEntry.StartUpMode
SecurityAuditingPresent = try { [bool]::Parse($GPOEntry.SecurityDescriptor.AuditingPresent.'#text') } catch { $null };
SecurityPermissionsPresent = try { [bool]::Parse($GPOEntry.SecurityDescriptor.PermissionsPresent.'#text') } catch { $null };
SecurityDescriptor = $GPOEntry.SecurityDescriptor
}
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
+36
View File
@@ -0,0 +1,36 @@
function ConvertTo-SystemServicesNT {
[cmdletBinding()]
param(
[Array] $GPOList
)
foreach ($GPOEntry in $GPOList) {
foreach ($Service in $GPOEntry.NTService) {
$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
Changed = [DateTime] $Service.Changed
GPOSettingOrder = $Service.GPOSettingOrder
#ServiceName = $Service.Name
ServiceName = $Service.Properties.serviceName #: AppIDSvc: AppIDSvc
ServiceStartupType = $Service.Properties.startupType #: NOCHANGE: NOCHANGE
ServiceAction = $Service.Properties.serviceAction #: START: START
Timeout = $Service.Properties.timeout #: 50: 50
FirstFailure = $Service.Properties.firstFailure #: REBOOT: REBOOT
SecondFailure = $Service.Properties.secondFailure #: REBOOT: REBOOT
ThirdFailure = $Service.Properties.thirdFailure #: REBOOT: REBOOT
ResetFailCountDelay = $Service.Properties.resetFailCountDelay #: 0: 0
RestartComputerDelay = $Service.Properties.restartComputerDelay #: 60000: 60000
Filter = $Service.Filter
}
$CreateGPO['Linked'] = $GPOEntry.Linked #: True
$CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1
$CreateGPO['Links'] = $GPOEntry.Links #: area1.local
[PSCustomObject] $CreateGPO
}
}
}
-32
View File
@@ -1,32 +0,0 @@
function Get-XMLAccount {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects
foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) {
foreach ($Key in $ExtensionType.Account) {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
Name = $Key.Name
Type = $Key.Type
SettingNumber = $Key.SettingNumber
SettingBoolean = if ($Key.SettingBoolean -eq 'true') { $true } elseif ($Key.SettingBoolean -eq 'false') { $false } else { $null }
}
}
}
}
}
}
-63
View File
@@ -1,63 +0,0 @@
function Get-XMLAutologon {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects
foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) {
if ($ExtensionType.RegistrySettings.Registry.Properties.Key -ne 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon') {
continue
}
$Autologon = [ordered] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
AutoAdminLogon = $null
DefaultDomainName = $null
DefaultUserName = $null
DefaultPassword = $null
}
foreach ($Key in $ExtensionType.RegistrySettings.Registry) {
if ($Key.Properties.key -eq 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon') {
<#
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $Linked
LinksCount = $LinksCount
GpoType = $Type
Changed = [DateTime] $Key.changed
GPOSettingOrder = $Key.GPOSettingOrder
hive = $Key.Properties.hive #: HKEY_LOCAL_MACHINE
key = $Key.Properties.key #: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
name = $Key.Properties.name #: AutoAdminLogon
type = $Key.Properties.type #: REG_SZ
value = $Key.Properties.value #
Filters = $Key.Filters
}
#>
if ($Key.Properties.Name -eq 'AutoAdminLogon') {
$Autologon['AutoAdminLogon'] = [bool] $Key.Properties.value
} elseif ($Key.Properties.Name -eq 'DefaultDomainName') {
$Autologon['DefaultDomainName'] = $Key.Properties.value
} elseif ($Key.Properties.Name -eq 'DefaultUserName') {
$Autologon['DefaultUserName'] = $Key.Properties.value
} elseif ($Key.Properties.Name -eq 'DefaultPassword') {
$Autologon['DefaultPassword'] = $Key.Properties.value
}
}
}
[PSCustomObject] $Autologon
}
}
}
}
-31
View File
@@ -1,31 +0,0 @@
function Get-XMLGPOTypes {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$Types = [ordered] @{
User = [System.Collections.Generic.List[string]]::new()
Computer = [System.Collections.Generic.List[string]]::new()
All = $null
}
[Array] $TypesReturn = foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) {
$GPOSettingType = ($ExtensionType.type -split ':')[1]
# add to hashtable
$Types["$Type"].Add($GPOSettingType)
# add to array
$GPOSettingType
}
}
}
$Types.Computer = $Types.Computer | Sort-Object -Unique
$Types.User = $Types.User | Sort-Object -Unique
$Types.All = $TypesReturn | Sort-Object -Unique
$Types
}
-93
View File
@@ -1,93 +0,0 @@
function Get-XMLLocalUserGroups {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects
foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension.LocalUsersAndGroups) {
foreach ($NestedType in @('User', 'Group')) {
if ($GPOOutput.$Type.ExtensionData.Extension.LocalUsersAndGroups.$NestedType) {
foreach ($Entry in $GPOOutput.$Type.ExtensionData.Extension.LocalUsersAndGroups.$NestedType) {
if ($Entry.Properties.Members) {
foreach ($Members in $Entry.Properties.Members) {
foreach ($Member in $Members.Member) {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
Name = $Entry.name
Changed = [DateTime] $Entry.changed
GPOSettingOrder = $Entry.GPOSettingOrder
Filters = $Entry.Filters
ActionType = $NestedType
Action = $Entry.Properties.Action
UserName = $Entry.Properties.userName
NewName = $Entry.Properties.newName
Description = $Entry.Properties.description
DeleteAllUsers = [bool] $Entry.Properties.deleteAllUsers
DeleteAllGroups = [bool] $Entry.Properties.deleteAllGroups
RemoveAccounts = [bool] $Entry.Properties.removeAccounts
GroupSid = $Entry.Properties.groupSid
GroupName = $Entry.Properties.groupName
MembersName = $Member.Name
MembersAction = $Member.Action
MembersSid = $Member.Sid
FullName = $Entry.Properties.fullName
AccountCpassword = $Entry.Properties.cpassword
AccountChangeLogon = [bool] $Entry.Properties.changeLogon
AccountNoChange = [bool] $Entry.Properties.noChange
AccountNeverExpires = [bool] $Entry.Properties.neverExpires
AccountDisabled = [bool] $Entry.Properties.acctDisabled
SubAuthority = $Entry.Properties.subAuthority
}
}
}
} else {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
Name = $Entry.name
Changed = [DateTime] $Entry.changed
GPOSettingOrder = $Entry.GPOSettingOrder
Filters = $Entry.Filters
ActionType = $NestedType
Action = $Entry.Properties.Action
UserName = $Entry.Properties.userName
NewName = $Entry.Properties.newName
Description = $Entry.Properties.description
DeleteAllUsers = [bool] $Entry.Properties.deleteAllUsers
DeleteAllGroups = [bool] $Entry.Properties.deleteAllGroups
RemoveAccounts = [bool] $Entry.Properties.removeAccounts
GroupSid = $Entry.Properties.groupSid
GroupName = $Entry.Properties.groupName
MembersName = $null
MembersAction = $null
MembersSid = $null
FullName = $Entry.Properties.fullName
AccountCpassword = $Entry.Properties.cpassword
AccountChangeLogon = [bool] $Entry.Properties.changeLogon
AccountNoChange = [bool] $Entry.Properties.noChange
AccountNeverExpires = [bool] $Entry.Properties.neverExpires
AccountDisabled = [bool] $Entry.Properties.acctDisabled
SubAuthority = $Entry.Properties.subAuthority
}
}
}
}
}
}
}
}
-41
View File
@@ -1,41 +0,0 @@
function Get-XMLRegistryPolicies {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects
foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) {
foreach ($Key in $ExtensionType.Policy) {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
PolicyName = $Key.Name
PolicyState = $Key.State
PolicyCategory = $Key.Category
PolicySupported = $Key.Supported
PolicyExplain = $Key.Explain
PolicyCheckBox = $Key.CheckBox
PolicyText = $Key.Text
DropDownList = $Key.DropDownList
PolicyEditText = $Key.EditText
<#
Name State Value
---- ----- -----
Target group name for this computer Enabled de00_wsus3_measuring_devices
#>
}
}
}
}
}
}
-35
View File
@@ -1,35 +0,0 @@
function Get-XMLRegistrySettings {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects
foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) {
foreach ($Key in $ExtensionType.RegistrySettings.Registry) {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
Changed = [DateTime] $Key.changed
GPOSettingOrder = $Key.GPOSettingOrder
Hive = $Key.Properties.hive #: HKEY_LOCAL_MACHINE
Key = $Key.Properties.key #: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Name = $Key.Properties.name #: AutoAdminLogon
Type = $Key.Properties.type #: REG_SZ
Value = $Key.Properties.value #
Filters = $Key.Filters
}
}
}
}
}
}
-49
View File
@@ -1,49 +0,0 @@
function Get-XMLScripts {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects
foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) {
foreach ($Key in $ExtensionType.Script) {
if ($FullObjects) {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
Command = $Key.Command
Parameters = $Key.Parameters
Type = $Key.Type
Order = $Key.Order
RunOrder = $Key.RunOrder
}
} else {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
Command = $Key.Command
Parameters = $Key.Parameters
type = $Key.Type
Order = $Key.Order
RunOrder = $Key.RunOrder
}
}
}
}
}
}
}
-29
View File
@@ -1,29 +0,0 @@
function Get-XMLSecurityOptions {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects
foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) {
foreach ($Key in $ExtensionType.SecurityOptions) {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
SystemAccessPolicyName = $Key.SystemAccessPolicyName
SettingNumber = $Key.SettingNumber
}
}
}
}
}
}
-83
View File
@@ -1,83 +0,0 @@
function Get-XMLSoftwareInstallation {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects
foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) {
foreach ($Key in $ExtensionType.MsiApplication) {
if ($FullObjects) {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
Identifier = $Key.Identifier #: { 10495e9e-79c1-4a32-b278-a24cd495437f }
Name = $Key.Name #: Local Administrator Password Solution (2)
Path = $Key.Path #: \\area1.local\SYSVOL\area1.local\Policies\ { 5F5042A0-008F-45E3-8657-79C87BD002E3 }\LAPS.x64.msi
MajorVersion = $Key.MajorVersion #: 6
MinorVersion = $Key.MinorVersion #: 2
LanguageId = $Key.LanguageId #: 1033
Architecture = $Key.Architecture #: 9
IgnoreLanguage = if ($Key.IgnoreLanguage -eq 'true') { $true } else { $false } #: false
Allowx86Onia64 = if ($Key.Allowx86Onia64 -eq 'true') { $true } else { $false } #: true
SupportURL = $Key.SupportURL #:
AutoInstall = if ($Key.AutoInstall -eq 'true') { $true } else { $false } #: true
DisplayInARP = if ($Key.DisplayInARP -eq 'true') { $true } else { $false } #: true
IncludeCOM = if ($Key.IncludeCOM -eq 'true') { $true } else { $false } #: true
SecurityDescriptor = $Key.SecurityDescriptor #: SecurityDescriptor
DeploymentType = $Key.DeploymentType #: Assign
ProductId = $Key.ProductId #: { ea8cb806-c109 - 4700 - 96b4-f1f268e5036c }
ScriptPath = $Key.ScriptPath #: \\area1.local\SysVol\area1.local\Policies\ { 5F5042A0-008F-45E3-8657-79C87BD002E3 }\Machine\Applications\ { EAC9B821-FB4D - 457A-806F-E5B528D1E41A }.aas
DeploymentCount = $Key.DeploymentCount #: 0
InstallationUILevel = $Key.InstallationUILevel #: Maximum
Upgrades = if ($Key.Upgrades.Mandatory -eq 'true') { $true } else { $false } #: Upgrades
UninstallUnmanaged = if ($Key.UninstallUnmanaged -eq 'true') { $true } else { $false } #: false
LossOfScopeAction = $Key.LossOfScopeAction #: Unmanage
}
} else {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
Identifier = $Key.Identifier #: { 10495e9e-79c1-4a32-b278-a24cd495437f }
Name = $Key.Name #: Local Administrator Password Solution (2)
Path = $Key.Path #: \\area1.local\SYSVOL\area1.local\Policies\ { 5F5042A0-008F-45E3-8657-79C87BD002E3 }\LAPS.x64.msi
MajorVersion = $Key.MajorVersion #: 6
MinorVersion = $Key.MinorVersion #: 2
LanguageId = $Key.LanguageId #: 1033
Architecture = $Key.Architecture #: 9
IgnoreLanguage = if ($Key.IgnoreLanguage -eq 'true') { $true } else { $false } #: false
Allowx86Onia64 = if ($Key.Allowx86Onia64 -eq 'true') { $true } else { $false } #: true
SupportURL = $Key.SupportURL #:
AutoInstall = if ($Key.AutoInstall -eq 'true') { $true } else { $false } #: true
DisplayInARP = if ($Key.DisplayInARP -eq 'true') { $true } else { $false } #: true
IncludeCOM = if ($Key.IncludeCOM -eq 'true') { $true } else { $false } #: true
SecurityDescriptor = $Key.SecurityDescriptor #: SecurityDescriptor
DeploymentType = $Key.DeploymentType #: Assign
ProductId = $Key.ProductId #: { ea8cb806-c109 - 4700 - 96b4-f1f268e5036c }
ScriptPath = $Key.ScriptPath #: \\area1.local\SysVol\area1.local\Policies\ { 5F5042A0-008F-45E3-8657-79C87BD002E3 }\Machine\Applications\ { EAC9B821-FB4D - 457A-806F-E5B528D1E41A }.aas
DeploymentCount = $Key.DeploymentCount #: 0
InstallationUILevel = $Key.InstallationUILevel #: Maximum
Upgrades = if ($Key.Upgrades.Mandatory -eq 'true') { $true } else { $false } #: Upgrades
UninstallUnmanaged = if ($Key.UninstallUnmanaged -eq 'true') { $true } else { $false } #: false
LossOfScopeAction = $Key.LossOfScopeAction #: Unmanage
}
}
}
}
}
}
}
-30
View File
@@ -1,30 +0,0 @@
function Get-XMLSystemServices {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[System.Xml.XmlElement[]] $GPOOutput,
[string] $Splitter = [System.Environment]::NewLine,
[switch] $FullObjects
)
$LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects
foreach ($Type in @('User', 'Computer')) {
if ($GPOOutput.$Type.ExtensionData.Extension) {
foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) {
foreach ($Key in $ExtensionType.SystemServices) {
[PSCustomObject] @{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.Guid
Linked = $LinksInformation.Linked
LinksCount = $LinksInformation.LinksCount
Links = $LinksInformation.Links
GpoType = $Type
Name = $Key.Name
StartupMode = $Key.StartupMode
}
}
}
}
}
}
-76
View File
@@ -1,76 +0,0 @@
$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
}
@@ -1,33 +0,0 @@
$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 } }
}
}
-77
View File
@@ -1,77 +0,0 @@
$SecurityOptions = @{
Category = 'SecuritySettings'
Settings = 'SecurityOptions'
# This is to make sure we're not loosing anything
# We will detect this and if something is missing provide details
PossibleProperties = @(
'KeyName'
'SettingNumber'
'Display'
'SystemAccessPolicyName'
'SettingString'
)
Translate = [ordered] @{
'KeyName' = 'KeyName'
'KeyDisplayName' = 'Display', 'Name'
'KeyDisplayUnits' = 'Display', 'Units'
'KeyDisplayBoolean' = 'Display', 'DisplayBoolean'
'KeyDisplayString' = 'Display', 'DisplayString'
'SystemAccessPolicyName' = 'SystemAccessPolicyName'
'SettingString' = 'SettingString'
'SettingNumber' = 'SettingNumber'
}
Types = [ordered] @{
'KeyDisplayBoolean' = { try { [bool]::Parse($args) } catch { $null } }
}
}
$LugsSettingsLocalUsersAndGroups = @{
PossibleProperties = @(
'clsid'
'Group'
'User'
)
CustomCode = {
}
<#
LoopOver = @{
User = @{
}
Group = @{
}
}
#>
<#
Translate = [ordered] @{
Name = #= $Entry.name
Changed = #= [DateTime] $Entry.changed
GPOSettingOrder = #= $Entry.GPOSettingOrder
Filters = #= $Entry.Filters
ActionType = #= $NestedType
Action = #= $Entry.Properties.Action
UserName = #= $Entry.Properties.userName
NewName = #= $Entry.Properties.newName
Description = #= $Entry.Properties.description
DeleteAllUsers = #= [bool] $Entry.Properties.deleteAllUsers
DeleteAllGroups = #= [bool] $Entry.Properties.deleteAllGroups
RemoveAccounts = #= [bool] $Entry.Properties.removeAccounts
GroupSid = #= $Entry.Properties.groupSid
GroupName = #= $Entry.Properties.groupName
MembersName = #= $Member.Name
MembersAction = #= $Member.Action
MembersSid = #= $Member.Sid
FullName = #= $Entry.Properties.fullName
AccountCpassword = #= $Entry.Properties.cpassword
AccountChangeLogon = #= [bool] $Entry.Properties.changeLogon
AccountNoChange = #= [bool] $Entry.Properties.noChange
AccountNeverExpires= #= [bool] $Entry.Properties.neverExpires
AccountDisabled = #= [bool] $Entry.Properties.acctDisabled
SubAuthority = #= $Entry.Properties.subAuthority
}
#>
}
+3 -105
View File
@@ -7,111 +7,9 @@
[string] $Settings
)
if ($Category -and $Settings -and $InputData) {
} else {
return
}
# 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) {
if ($Property -notin $Script:GPODitionary[$Report]['PossibleProperties']) {
$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 ','))"
}
# Here we try to translate given GPO entries according to predefined dictionary - so called prettify
# 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
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
#$Script:GPODitionary[$Report]['LoopOver'][$Key].GetEnumerator() | Where-Object { $_.Value -is [System.Collections.IDictionary] }
$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
}
}
} 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
if ($Script:GPODitionary[$Report]['Code']) {
$Script:GPOList = $InputData.$Category.$Settings
return & $Script:GPODitionary[$Report]['Code']
}
}
}
+46 -3
View File
@@ -1,7 +1,50 @@
$Script:GPODitionary = @{
SecurityOptions = $SecurityOptions
RegistrySettings = $RegistrySettings
RegistrySettingsCollection = $RegistrySettingsCollection
Autologon = [ordered] @{
Category = 'RegistrySettings'
Settings = 'RegistrySettings'
Code = {
ConvertTo-RegistryAutologon -GPOList $GPOList
}
}
RegistrySettings = [ordered] @{
Category = 'RegistrySettings'
Settings = 'RegistrySettings'
Code = {
ConvertTo-RegistrySettings -GPOList $GPOList
}
}
RegistrySettingsCollection = [ordered] @{
Category = 'RegistrySettings'
Settings = 'RegistrySettings'
Code = {
ConvertTo-RegistrySettingsCollection -GPOList $GPOList
}
}
SecurityOptions = [ordered] @{
Category = 'SecuritySettings'
Settings = 'SecurityOptions'
Code = {
ConvertTo-SecurityOptions -GPOList $GPOList
}
}
SystemServices = [ordered] @{
Description = ''
GPOPath = 'Computer Configuration -> Policies -> Windows Settings -> Security Settings -> System Services'
Category = 'SecuritySettings'
Settings = 'SystemServices'
Code = {
ConvertTo-SystemServices -GPOList $GPOList
}
}
SystemServicesNT = [ordered] @{
Description = ''
GPOPath = 'Computer Configuration -> Preferences -> Control Pannel Settings -> Services'
Category = 'ServiceSettings'
Settings = 'NTServices'
Code = {
ConvertTo-SystemServicesNT -GPOList $GPOList
}
}
#LugsSettings = @{
# LocalUsersAndGroups = $LugsSettingsLocalUsersAndGroups