mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-07-26 20:00:09 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a519004f5 | |||
| 8234c6cf50 | |||
| f50a495690 | |||
| 6c2e29122e | |||
| 250683e830 | |||
| 0f04582b42 | |||
| d9de90718d | |||
| e8651b71fd | |||
| ecdd6fb8ec | |||
| 945e993843 | |||
| fdf78ecadb | |||
| fc9b191578 | |||
| 04e5eaf63c | |||
| 494b1582ca | |||
| c33b820e36 | |||
| cfeb0098a6 |
+4
-4
@@ -5,9 +5,9 @@
|
||||
CompatiblePSEditions = 'Desktop'
|
||||
Copyright = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.'
|
||||
Description = 'Group Policy Eater is a PowerShell module that aims to gather information about Group Policies but also allows fixing issues that you may find in them.'
|
||||
FunctionsToExport = 'Add-GPOPermission', 'Add-GPOZaurrPermission', 'Backup-GPOZaurr', 'Clear-GPOZaurrSysvolDFSR', 'ConvertFrom-CSExtension', 'Find-CSExtension', 'Get-GPOZaurr', 'Get-GPOZaurrAD', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrDictionary', 'Get-GPOZaurrFiles', 'Get-GPOZaurrFilesPolicyDefinition', 'Get-GPOZaurrFolders', 'Get-GPOZaurrInheritance', 'Get-GPOZaurrLegacyFiles', 'Get-GPOZaurrLink', 'Get-GPOZaurrLinkSummary', 'Get-GPOZaurrOwner', 'Get-GPOZaurrPassword', 'Get-GPOZaurrPermission', 'Get-GPOZaurrPermissionConsistency', 'Get-GPOZaurrSysvol', 'Get-GPOZaurrSysvolDFSR', 'Get-GPOZaurrWMI', 'Invoke-GPOZaurr', 'Invoke-GPOZaurrPermission', 'Invoke-GPOZaurrSupport', 'New-GPOZaurrWMI', 'Remove-GPOPermission', 'Remove-GPOZaurr', 'Remove-GPOZaurrFolders', 'Remove-GPOZaurrLegacyFiles', 'Remove-GPOZaurrOrphanedSysvolFolders', 'Remove-GPOZaurrPermission', 'Remove-GPOZaurrWMI', 'Repair-GPOZaurrPermissionConsistency', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles', 'Set-GPOOwner', 'Set-GPOZaurrOwner'
|
||||
FunctionsToExport = 'Add-GPOPermission', 'Add-GPOZaurrPermission', 'Backup-GPOZaurr', 'Clear-GPOZaurrSysvolDFSR', 'ConvertFrom-CSExtension', 'Find-CSExtension', 'Get-GPOZaurr', 'Get-GPOZaurrAD', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrDictionary', 'Get-GPOZaurrFiles', 'Get-GPOZaurrFilesPolicyDefinition', 'Get-GPOZaurrFolders', 'Get-GPOZaurrInheritance', 'Get-GPOZaurrLegacyFiles', 'Get-GPOZaurrLink', 'Get-GPOZaurrLinkSummary', 'Get-GPOZaurrOwner', 'Get-GPOZaurrPassword', 'Get-GPOZaurrPermission', 'Get-GPOZaurrPermissionConsistency', 'Get-GPOZaurrPermissionSummary', 'Get-GPOZaurrSysvol', 'Get-GPOZaurrSysvolDFSR', 'Get-GPOZaurrWMI', 'Invoke-GPOZaurr', 'Invoke-GPOZaurrPermission', 'Invoke-GPOZaurrSupport', 'New-GPOZaurrWMI', 'Remove-GPOPermission', 'Remove-GPOZaurr', 'Remove-GPOZaurrFolders', 'Remove-GPOZaurrLegacyFiles', 'Remove-GPOZaurrOrphanedSysvolFolders', 'Remove-GPOZaurrPermission', 'Remove-GPOZaurrWMI', 'Repair-GPOZaurrPermissionConsistency', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles', 'Set-GPOOwner', 'Set-GPOZaurrOwner'
|
||||
GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde'
|
||||
ModuleVersion = '0.0.52'
|
||||
ModuleVersion = '0.0.59'
|
||||
PowerShellVersion = '5.1'
|
||||
PrivateData = @{
|
||||
PSData = @{
|
||||
@@ -17,11 +17,11 @@
|
||||
}
|
||||
}
|
||||
RequiredModules = @{
|
||||
ModuleVersion = '0.0.166'
|
||||
ModuleVersion = '0.0.168'
|
||||
ModuleName = 'PSSharedGoods'
|
||||
Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'
|
||||
}, @{
|
||||
ModuleVersion = '0.0.66'
|
||||
ModuleVersion = '0.0.67'
|
||||
ModuleName = 'ADEssentials'
|
||||
Guid = '9fc9fd61-7f11-4f4b-a527-084086f1905f'
|
||||
}, 'ActiveDirectory', 'GroupPolicy', 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility'
|
||||
|
||||
@@ -6,12 +6,6 @@ function ConvertTo-XMLGenericPublicKey {
|
||||
)
|
||||
|
||||
$SkipNames = ('Name', 'LocalName', 'NamespaceURI', 'Prefix', 'NodeType', 'ParentNode', 'OwnerDocument', 'IsEmpty', 'Attributes', 'HasAttributes', 'SchemaInfo', 'InnerXml', 'InnerText', 'NextSibling', 'PreviousSibling', 'ChildNodes', 'FirstChild', 'LastChild', 'HasChildNodes', 'IsReadOnly', 'OuterXml', 'BaseURI', 'PreviousText')
|
||||
<#
|
||||
$UsedNames = [System.Collections.Generic.List[string]]::new()
|
||||
[Array] $Settings = foreach ($Cat in $Category) {
|
||||
$GPO.DataSet | Where-Object { $null -ne $_.$Cat }
|
||||
}
|
||||
#>
|
||||
foreach ($Setting in $GPO.DataSet) {
|
||||
$CreateGPO = [ordered]@{
|
||||
DisplayName = $GPO.DisplayName
|
||||
@@ -28,8 +22,6 @@ function ConvertTo-XMLGenericPublicKey {
|
||||
$CreateGPO['SecurityDescriptor'] = $GPO.SecurityDescriptor # : SecurityDescriptor
|
||||
$CreateGPO['FilterDataAvailable'] = $GPO.FilterDataAvailable # : True
|
||||
|
||||
|
||||
#$Divider = $SettingName[0]
|
||||
$Name = $SettingName[1]
|
||||
#$Name = Format-ToTitleCase -Text $Setting.Name -RemoveWhiteSpace -RemoveChar ',', '-', "'", '\(', '\)', ':'
|
||||
$CreateGPO['Name'] = $Name # $Setting.Name
|
||||
@@ -37,6 +29,8 @@ function ConvertTo-XMLGenericPublicKey {
|
||||
|
||||
#foreach ($Property in ($Setting.Properties | Get-Member -MemberType Properties).Name) {
|
||||
|
||||
ConvertTo-XMLNested -CreateGPO $CreateGPO -Setting $Setting -SkipNames $SkipNames #-Name $Name
|
||||
<#
|
||||
$Properties = $Setting.PSObject.Properties.Name | Where-Object { $_ -notin $SkipNames }
|
||||
foreach ($Property in $Properties) {
|
||||
If ($Property -eq 'Value') {
|
||||
@@ -54,26 +48,20 @@ function ConvertTo-XMLGenericPublicKey {
|
||||
} else {
|
||||
throw
|
||||
}
|
||||
|
||||
<#
|
||||
foreach ($SubProperty in $SubProperties) {
|
||||
if ($SubProperty -eq 'Name') {
|
||||
|
||||
} elseif ($SubProperty -eq 'String') {
|
||||
|
||||
} elseif ($SubProperty -eq 'Number') {
|
||||
|
||||
}
|
||||
#$Name = Format-CamelCaseToDisplayName -Text $SubProperty #-RemoveWhiteSpace -RemoveChar ',', '-', "'", '\(', '\)', ':'
|
||||
#$CreateGPO[$Name] = $Setting.$Property.$SubProperty
|
||||
}
|
||||
#>
|
||||
}
|
||||
} else {
|
||||
$Name = Format-CamelCaseToDisplayName -Text $Property #-RemoveWhiteSpace -RemoveChar ',', '-', "'", '\(', '\)', ':'
|
||||
$CreateGPO[$Name] = $Setting.$Property
|
||||
if ($Setting.$Property -is [System.Xml.XmlElement]) {
|
||||
$SubPropeties = $Setting.$Property.PSObject.Properties.Name | Where-Object { $_ -notin $SkipNames }
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
$CreateGPO[$Name] = $Setting.$Property
|
||||
}
|
||||
}
|
||||
}
|
||||
#>
|
||||
|
||||
|
||||
$CreateGPO['Filters'] = $Setting.Filters
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
function ConvertTo-XMLNested {
|
||||
[cmdletBinding()]
|
||||
param(
|
||||
[System.Collections.IDictionary] $CreateGPO,
|
||||
[System.Xml.XmlElement] $Setting,
|
||||
[string[]] $SkipNames,
|
||||
[string] $Name
|
||||
)
|
||||
|
||||
$Properties = $Setting.PSObject.Properties.Name | Where-Object { $_ -notin $SkipNames }
|
||||
$TempName = $Name
|
||||
foreach ($Property in $Properties) {
|
||||
If ($Property -eq 'Value') {
|
||||
if ($Setting.$Property) {
|
||||
#$SubProperties = $Setting.$Property.PSObject.Properties.Name
|
||||
if ($Setting.$Property.Name) {
|
||||
$Name = $Setting.$Property.Name
|
||||
} else {
|
||||
if (-not $Name) {
|
||||
$Name = 'Value'
|
||||
}
|
||||
}
|
||||
if ($Setting.$Property.Number) {
|
||||
$CreateGPO[$Name] = $Setting.$Property.Number
|
||||
} elseif ($Setting.$Property.String) {
|
||||
$CreateGPO[$Name] = $Setting.$Property.String
|
||||
} else {
|
||||
$CreateGPO[$Name] = $Setting.$Property
|
||||
|
||||
#throw
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$Name = -join ($Name, $Property)
|
||||
$Name = Format-CamelCaseToDisplayName -Text $Name #-RemoveWhiteSpace -RemoveChar ',', '-', "'", '\(', '\)', ':'
|
||||
if ($Setting.$Property -is [System.Xml.XmlElement]) {
|
||||
#$SubPropeties = $Setting.$Property.PSObject.Properties.Name | Where-Object { $_ -notin $SkipNames }
|
||||
|
||||
|
||||
ConvertTo-XMLNested -Setting $Setting.$Property -CreateGPO $CreateGPO -Name $Name -SkipNames $SkipNames
|
||||
|
||||
|
||||
} else {
|
||||
$CreateGPO[$Name] = $Setting.$Property
|
||||
}
|
||||
}
|
||||
$Name = $TempName
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
$OrganizationalUnits = Get-ADOrganizationalUnit -Filter * -Properties gpOptions, canonicalName -Server $ForestInformation['QueryServers'][$Domain]['HostName'][0]
|
||||
foreach ($OU in $OrganizationalUnits) {
|
||||
$InheritanceInformation = [Ordered] @{
|
||||
DistinguishedName = $OU.DistinguishedName
|
||||
CanonicalName = $OU.canonicalName
|
||||
BlockedInheritance = if ($OU.gpOptions -eq 1) { $true } else { $false }
|
||||
}
|
||||
@@ -34,8 +33,8 @@
|
||||
if ($InheritanceInformation.BlockedInheritance -eq $true) {
|
||||
$InheritanceInformation['UsersCount'] = $null
|
||||
$InheritanceInformation['ComputersCount'] = $null
|
||||
$InheritanceInformation['Users'] = Get-ADUser -SearchBase $InheritanceInformation.DistinguishedName -Server $ForestInformation['QueryServers'][$Domain]['HostName'][0] -Filter *
|
||||
$InheritanceInformation['Computers'] = Get-ADComputer -SearchBase $InheritanceInformation.DistinguishedName -Server $ForestInformation['QueryServers'][$Domain]['HostName'][0] -Filter *
|
||||
[Array] $InheritanceInformation['Users'] = (Get-ADUser -SearchBase $OU.DistinguishedName -Server $ForestInformation['QueryServers'][$Domain]['HostName'][0] -Filter *).SamAccountName
|
||||
[Array] $InheritanceInformation['Computers'] = (Get-ADComputer -SearchBase $OU.DistinguishedName -Server $ForestInformation['QueryServers'][$Domain]['HostName'][0] -Filter *).SamAccountName
|
||||
$InheritanceInformation['UsersCount'] = $InheritanceInformation['Users'].Count
|
||||
$InheritanceInformation['ComputersCount'] = $InheritanceInformation['Computers'].Count
|
||||
} else {
|
||||
@@ -53,6 +52,7 @@
|
||||
[PSCustomObject] $InheritanceInformation
|
||||
}
|
||||
}
|
||||
$InheritanceInformation['DistinguishedName'] = $OU.DistinguishedName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
function Get-GPOZaurrPermissionSummary {
|
||||
[cmdletBinding()]
|
||||
param(
|
||||
[validateSet('AuthenticatedUsers', 'DomainComputers', 'Unknown', 'WellKnownAdministrative', 'NotWellKnown', 'NotWellKnownAdministrative', 'NotAdministrative', 'Administrative', 'All')][string[]] $Type = 'All',
|
||||
[validateSet('Allow', 'Deny', 'All')][string] $PermitType = 'All',
|
||||
[Microsoft.GroupPolicy.GPPermissionType[]] $IncludePermissionType,
|
||||
[Microsoft.GroupPolicy.GPPermissionType[]] $ExcludePermissionType,
|
||||
[switch] $IncludeOwner,
|
||||
|
||||
[alias('ForestName')][string] $Forest,
|
||||
[string[]] $ExcludeDomains,
|
||||
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
|
||||
[System.Collections.IDictionary] $ExtendedForestInformation,
|
||||
|
||||
[string] $Separator
|
||||
)
|
||||
|
||||
$Permissions = Get-GPOZaurrPermission -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation -IncludePermissionType $IncludePermissionType -ExcludePermissionType $ExcludePermissionType -Type $Type -PermitType $PermitType -IncludeOwner:$IncludeOwner
|
||||
$Entries = foreach ($Permission in $Permissions) {
|
||||
[PSCustomObject] @{
|
||||
Name = $Permission.Name
|
||||
Permission = $Permission.Permission
|
||||
PermissionType = $Permission.PermissionType
|
||||
Sid = $Permission.Sid
|
||||
SidType = $Permission.SidType
|
||||
DisplayName = $Permission.DisplayName
|
||||
DomainName = $Permission.DomainName
|
||||
Domain = $Domain
|
||||
}
|
||||
}
|
||||
$Entries | Group-Object -Property Permission, SidType, Name, DomainName, PermissionType | ForEach-Object {
|
||||
$Property = $_.Name -split ', '
|
||||
|
||||
if ($Property[0] -eq 'GpoOwner') {
|
||||
[PSCustomObject] @{
|
||||
Permission = $Property[0]
|
||||
Type = $Property[1]
|
||||
Name = $Property[2]
|
||||
DomainName = $Property[3]
|
||||
PermissionType = 'Allow'
|
||||
GPOCount = $_.Count
|
||||
GPONames = if ($Separator) { $_.Group.DisplayName -join $Separator } else { $_.Group.DisplayName }
|
||||
}
|
||||
} elseif ($Property.Count -eq 5) {
|
||||
[PSCustomObject] @{
|
||||
Permission = $Property[0]
|
||||
Type = $Property[1]
|
||||
Name = $Property[2]
|
||||
DomainName = $Property[3]
|
||||
PermissionType = if ($Property[4]) { $Property[4] } else { 'Owner' }
|
||||
GPOCount = $_.Count
|
||||
GPONames = if ($Separator) { $_.Group.DisplayName -join $Separator } else { $_.Group.DisplayName }
|
||||
}
|
||||
} else {
|
||||
[PSCustomObject] @{
|
||||
Permission = $Property[0]
|
||||
Type = $Property[1]
|
||||
Name = ''
|
||||
DomainName = $Property[2]
|
||||
PermissionType = if ($Property[3]) { $Property[3] } else { 'Owner' }
|
||||
GPOCount = $_.Count
|
||||
GPONames = if ($Separator) { $_.Group.DisplayName -join $Separator } else { $_.Group.DisplayName }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,11 +49,25 @@ That's it. Whenever there's a new version, you run the command, and you can enjo
|
||||
|
||||
## Changelog
|
||||
|
||||
- 0.0.52 - Unreleased
|
||||
- 0.0.59 - 26.08.2020
|
||||
- Improvement to `Get-GPOZaurrPermissionSummary`
|
||||
- 0.0.58 - 26.08.2020
|
||||
- Improvement to `Get-GPOZaurrPermissionSummary`
|
||||
- 0.0.57 - 26.08.2020
|
||||
- Improvement to `Get-GPOZaurrPermissionSummary`
|
||||
- 0.0.56 - 26.08.2020
|
||||
- Added `Get-GPOZaurrPermissionSummary`
|
||||
- 0.0.55 - 17.08.2020
|
||||
- Improved `Get-GPOZaurrInheritance`
|
||||
- 0.0.54 - 16.08.2020
|
||||
- Added `Invoke-GPOZaurrSupport` (WIP)
|
||||
- Added `ConvertFrom-CSExtension`
|
||||
- Added `Find-CSExtension`
|
||||
- Added `Get-GPOZaurrInheritance`
|
||||
- 0.0.53 - 16.08.2020
|
||||
- Bad release
|
||||
- 0.0.52 - 16.08.2020
|
||||
- Bad release
|
||||
- 0.0.51 - 2.08.2020
|
||||
- Updates to `Invoke-GPOZaurr` - still work in progress
|
||||
- Added `Get-GPOZaurrSysvolDFSR`
|
||||
|
||||
Reference in New Issue
Block a user