This commit is contained in:
Przemysław Kłys
2020-04-13 20:51:56 +02:00
parent 5af51e8022
commit 7dc64c484f
6 changed files with 45 additions and 18 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
$T = Get-GPOZaurrPermission -GPOName 'DC | PowerShell Logging' -Type Unknown #$T = Get-GPOZaurrPermission -GPOName 'DC | PowerShell Logging' -Type Unknown
#$T = Get-GPOZaurrPermission #-Type All #-SkipWellKnown -SkipAdministrative # -ExcludePermissionType GpoRead,GpoApply #| Out-HtmlView $T = Get-GPOZaurrPermission -ExcludePermissionType GpoRead,GpoApply #-Type All #-SkipWellKnown -SkipAdministrative # -ExcludePermissionType GpoRead,GpoApply #| Out-HtmlView
$T | Format-Table -AutoSize * $T | Format-Table -AutoSize *
#$T | Out-HtmlView -ScrollX -Filtering -Online -DisablePaging #$T | Out-HtmlView -ScrollX -Filtering -Online -DisablePaging
+4
View File
@@ -0,0 +1,4 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
$Owners = Get-GPOZaurr -owneronly
$Owners | Format-Table
+4 -4
View File
@@ -5,9 +5,9 @@
CompatiblePSEditions = 'Desktop' CompatiblePSEditions = 'Desktop'
Copyright = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.' Copyright = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.'
Description = 'Group Policy Eater' Description = 'Group Policy Eater'
FunctionsToExport = 'Backup-GPOZaurr', 'Get-GPOZaurr', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrPassword', 'Get-GPOZaurrPermission', 'Get-GPOZaurrWMI', 'New-GPOZaurrWMI', 'Remove-GPOZaurr', 'Remove-GPOZaurrPermission', 'Remove-GPOZaurrWMI', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles', 'Set-GPOZaurrOwner', 'Set-GPOZaurrWMI' FunctionsToExport = 'Backup-GPOZaurr', 'Get-GPOZaurr', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrPassword', 'Get-GPOZaurrPermission', 'Get-GPOZaurrWMI', 'New-GPOZaurrWMI', 'Remove-GPOZaurr', 'Remove-GPOZaurrPermission', 'Remove-GPOZaurrWMI', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles', 'Set-GPOZaurrOwner'
GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde' GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde'
ModuleVersion = '0.0.12' ModuleVersion = '0.0.14'
PowerShellVersion = '5.1' PowerShellVersion = '5.1'
PrivateData = @{ PrivateData = @{
PSData = @{ PSData = @{
@@ -17,11 +17,11 @@
} }
} }
RequiredModules = @{ RequiredModules = @{
ModuleVersion = '0.0.134' ModuleVersion = '0.0.135'
ModuleName = 'PSSharedGoods' ModuleName = 'PSSharedGoods'
Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe' Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'
}, @{ }, @{
ModuleVersion = '0.0.47' ModuleVersion = '0.0.48'
ModuleName = 'ADEssentials' ModuleName = 'ADEssentials'
Guid = '9fc9fd61-7f11-4f4b-a527-084086f1905f' Guid = '9fc9fd61-7f11-4f4b-a527-084086f1905f'
}, 'ActiveDirectory', 'GroupPolicy', 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility' }, 'ActiveDirectory', 'GroupPolicy', 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility'
+29 -2
View File
@@ -3,7 +3,9 @@
param( param(
[XML] $XMLContent, [XML] $XMLContent,
[Microsoft.GroupPolicy.Gpo] $GPO, [Microsoft.GroupPolicy.Gpo] $GPO,
[switch] $PermissionsOnly [switch] $PermissionsOnly,
[switch] $OwnerOnly,
[System.Collections.IDictionary] $ADAdministrativeGroups
) )
if ($XMLContent.GPO.LinksTo) { if ($XMLContent.GPO.LinksTo) {
$Linked = $true $Linked = $true
@@ -34,7 +36,21 @@
} elseif ($UserEnabled -eq $false -and $ComputerEnabled -eq $true) { } elseif ($UserEnabled -eq $false -and $ComputerEnabled -eq $true) {
$Enabled = 'User configuration settings disabled' $Enabled = 'User configuration settings disabled'
} }
if (-not $PermissionsOnly) {
if ($XMLContent.GPO.SecurityDescriptor.Owner.Name.'#text') {
$AdministrativeGroup = $ADAdministrativeGroups['ByNetBIOS']["$($XMLContent.GPO.SecurityDescriptor.Owner.Name.'#text')"]
$WellKnown = ConvertFrom-SID -SID $XMLContent.GPO.SecurityDescriptor.Owner.SID.'#text' -OnlyWellKnown
if ($AdministrativeGroup) {
$OwnerType = 'Administrative'
} elseif ($WellKnown.Name) {
$OwnerType = 'WellKnown'
} else {
$OwnerType = 'NonAdministrative'
}
} else {
$OwnerType = 'EmptyOrUnknown'
}
}
if ($PermissionsOnly) { if ($PermissionsOnly) {
[PsCustomObject] @{ [PsCustomObject] @{
'DisplayName' = $XMLContent.GPO.Name 'DisplayName' = $XMLContent.GPO.Name
@@ -64,6 +80,16 @@
} }
} }
} }
} elseif ($OwnerOnly) {
[PsCustomObject] @{
'DisplayName' = $XMLContent.GPO.Name
'DomainName' = $XMLContent.GPO.Identifier.Domain.'#text'
'GUID' = $XMLContent.GPO.Identifier.Identifier.InnerText
'Enabled' = $Enabled
'Owner' = $XMLContent.GPO.SecurityDescriptor.Owner.Name.'#text'
'OwnerSID' = $XMLContent.GPO.SecurityDescriptor.Owner.SID.'#text'
'OwnerType' = $OwnerType
}
} else { } else {
[PsCustomObject] @{ [PsCustomObject] @{
'DisplayName' = $XMLContent.GPO.Name 'DisplayName' = $XMLContent.GPO.Name
@@ -93,6 +119,7 @@
'SDDL' = if ($Splitter -ne '') { $XMLContent.GPO.SecurityDescriptor.SDDL.'#text' -join $Splitter } else { $XMLContent.GPO.SecurityDescriptor.SDDL.'#text' } 'SDDL' = if ($Splitter -ne '') { $XMLContent.GPO.SecurityDescriptor.SDDL.'#text' -join $Splitter } else { $XMLContent.GPO.SecurityDescriptor.SDDL.'#text' }
'Owner' = $XMLContent.GPO.SecurityDescriptor.Owner.Name.'#text' 'Owner' = $XMLContent.GPO.SecurityDescriptor.Owner.Name.'#text'
'OwnerSID' = $XMLContent.GPO.SecurityDescriptor.Owner.SID.'#text' 'OwnerSID' = $XMLContent.GPO.SecurityDescriptor.Owner.SID.'#text'
'OwnerType' = $OwnerType
'ACL' = @( 'ACL' = @(
[PsCustomObject] @{ [PsCustomObject] @{
'Name' = $XMLContent.GPO.SecurityDescriptor.Owner.Name.'#text' 'Name' = $XMLContent.GPO.SecurityDescriptor.Owner.Name.'#text'
+6 -4
View File
@@ -11,9 +11,11 @@
[string[]] $GPOPath, [string[]] $GPOPath,
[switch] $PermissionsOnly, [switch] $PermissionsOnly,
[switch] $OwnerOnly,
[switch] $Limited [switch] $Limited
) )
Begin { Begin {
$ADAdministrativeGroups = Get-ADADministrativeGroups -Type DomainAdmins, EnterpriseAdmins -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
if (-not $GPOPath) { if (-not $GPOPath) {
$ForestInformation = Get-WinADForestDetails -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation $ForestInformation = Get-WinADForestDetails -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
} }
@@ -27,7 +29,7 @@
Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain" Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain"
if (-not $Limited) { if (-not $Limited) {
$XMLContent = Get-GPOReport -ID $_.ID -ReportType XML -Server $ForestInformation.QueryServers[$Domain].HostName[0] -Domain $Domain $XMLContent = Get-GPOReport -ID $_.ID -ReportType XML -Server $ForestInformation.QueryServers[$Domain].HostName[0] -Domain $Domain
Get-XMLGPO -XMLContent $XMLContent -GPO $_ -PermissionsOnly:$PermissionsOnly.IsPresent Get-XMLGPO -OwnerOnly:$OwnerOnly.IsPresent -XMLContent $XMLContent -GPO $_ -PermissionsOnly:$PermissionsOnly.IsPresent -ADAdministrativeGroups $ADAdministrativeGroups
} else { } else {
$_ $_
} }
@@ -37,7 +39,7 @@
Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain" Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain"
if (-not $Limited) { if (-not $Limited) {
$XMLContent = Get-GPOReport -ID $_.ID -ReportType XML -Server $ForestInformation.QueryServers[$Domain].HostName[0] -Domain $Domain $XMLContent = Get-GPOReport -ID $_.ID -ReportType XML -Server $ForestInformation.QueryServers[$Domain].HostName[0] -Domain $Domain
Get-XMLGPO -XMLContent $XMLContent -GPO $_ -PermissionsOnly:$PermissionsOnly.IsPresent Get-XMLGPO -OwnerOnly:$OwnerOnly.IsPresent -XMLContent $XMLContent -GPO $_ -PermissionsOnly:$PermissionsOnly.IsPresent -ADAdministrativeGroups $ADAdministrativeGroups
} else { } else {
$_ $_
} }
@@ -47,7 +49,7 @@
Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain" Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain"
if (-not $Limited) { if (-not $Limited) {
$XMLContent = Get-GPOReport -ID $_.ID -ReportType XML -Server $ForestInformation.QueryServers[$Domain].HostName[0] -Domain $Domain $XMLContent = Get-GPOReport -ID $_.ID -ReportType XML -Server $ForestInformation.QueryServers[$Domain].HostName[0] -Domain $Domain
Get-XMLGPO -XMLContent $XMLContent -GPO $_ -PermissionsOnly:$PermissionsOnly.IsPresent Get-XMLGPO -OwnerOnly:$OwnerOnly.IsPresent -XMLContent $XMLContent -GPO $_ -PermissionsOnly:$PermissionsOnly.IsPresent -ADAdministrativeGroups $ADAdministrativeGroups
} else { } else {
$_ $_
} }
@@ -59,7 +61,7 @@
Get-ChildItem -LiteralPath $Path -Recurse -Filter *.xml | ForEach-Object { Get-ChildItem -LiteralPath $Path -Recurse -Filter *.xml | ForEach-Object {
$XMLContent = [XML]::new() $XMLContent = [XML]::new()
$XMLContent.Load($_.FullName) $XMLContent.Load($_.FullName)
Get-XMLGPO -XMLContent $XMLContent -PermissionsOnly:$PermissionsOnly.IsPresent Get-XMLGPO -OwnerOnly:$OwnerOnly.IsPresent -XMLContent $XMLContent -PermissionsOnly:$PermissionsOnly.IsPresent
} }
} }
} }
-6
View File
@@ -1,6 +0,0 @@
function Set-GPOZaurrWMI {
[cmdletBinding()]
param(
)
}