This commit is contained in:
Przemysław Kłys
2020-04-10 16:48:15 +02:00
parent cfdd544491
commit 0d12bb9b05
4 changed files with 137 additions and 1 deletions
@@ -0,0 +1,16 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
#$GPOS = Get-GPOZaurr
#$GPOS | Format-Table -AutoSize
#$GPOS[0] | Format-List
#$GPOs[0].ACL | Format-Table -AutoSize
#Get-GPOZaurrPermissions | Format-Table -AutoSize
$T = Get-GPOZaurrPermissions #| Out-HtmlView
#$T[0] | Format-List *
$T | Format-Table -AutoSize
#$T[0].Trustee
#$T[0].Permission
#$T[0]
+1 -1
View File
@@ -5,7 +5,7 @@
CompatiblePSEditions = 'Desktop'
Copyright = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.'
Description = 'Group Policy Eater'
FunctionsToExport = 'Backup-GPOZaurr', 'Get-GPOZaurr', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrPassword', 'Get-GPOZaurrWMI', 'New-GPOZaurrWMI', 'Remove-GPOZaurr', 'Remove-GPOZaurrWMI', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles'
FunctionsToExport = 'Backup-GPOZaurr', 'Get-GPOZaurr', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrPassword', 'Get-GPOZaurrPermissions', 'Get-GPOZaurrWMI', 'New-GPOZaurrWMI', 'Remove-GPOZaurr', 'Remove-GPOZaurrWMI', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles'
GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde'
ModuleVersion = '0.0.6'
PowerShellVersion = '5.1'
+45
View File
@@ -0,0 +1,45 @@
function ConvertTo-TableFormat {
<#
.SYNOPSIS
Rebuild an object based on the Format Data for the object.
.DESCRIPTION
Allows an object to be rebuilt based on the view data for the object. Uses Select-Object to create a new PSCustomObject.
#>
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline)]
[Object]$InputObject
)
begin {
$isFirst = $true
}
process {
$format = if ($isFirst) {
$formatData = Get-FormatData -TypeName $InputObject.PSTypeNames | Select-Object -First 1
if ($formatData) {
$viewDefinition = $formatData.FormatViewDefinition | Where-Object Control -match 'TableControl'
for ($i = 0; $i -lt $viewDefinition.Control.Headers.Count; $i++) {
$name = $viewDefinition.Control.Headers[$i].Label
$displayEntry = $viewDefinition.Control.Rows.Columns[$i].DisplayEntry
if (-not $name) {
$name = $displayEntry.Value
}
$expression = switch ($displayEntry.ValueType) {
'Property' { $displayEntry.Value }
'ScriptBlock' { [ScriptBlock]::Create($displayEntry.Value) }
}
@{ Name = $name; Expression = $expression }
}
}
}
if ($format) {
$InputObject | Select-Object -Property $format
} else {
$InputObject
}
}
}
+75
View File
@@ -0,0 +1,75 @@
function Get-GPOZaurrPermissions {
[cmdletBinding()]
param(
[switch] $SkipWellKnownGroup,
[alias('ForestName')][string] $Forest,
[string[]] $ExcludeDomains,
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
[System.Collections.IDictionary] $ExtendedForestInformation
)
$ForestInformation = Get-WinADForestDetails -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
foreach ($Domain in $ForestInformation.Domains) {
$QueryServer = $ForestInformation['QueryServers'][$Domain]['HostName'][0]
Get-GPO -All -Domain $Domain -Server $QueryServer | ForEach-Object -Process {
$GPO = $_
<#
DisplayName : ALL | Enable RDP
DomainName : ad.evotec.xyz
Owner : EVOTEC\Domain Admins
Id : 051bcddf-cc11-427b-bdf0-684c0a6e3ddb
GpoStatus : AllSettingsEnabled
Description :
CreationTime : 07.08.2018 12:47:44
ModificationTime : 07.04.2020 22:09:24
UserVersion : AD Version: 1, SysVol Version: 1
ComputerVersion : AD Version: 1, SysVol Version: 1
WmiFilter :
#>
Get-GPPermission -Name $GPO.DisplayName -DomainName $GPO.DomainName -All -Server $QueryServer | ForEach-Object -Process {
$GPOPermission = $_
#$GPOPermissionFormatted = ConvertTo-TableFormat -InputObject $_
[PSCustomObject] @{
DisplayName = $GPO.DisplayName # : ALL | Enable RDP
GUID = $GPO.ID
DomainName = $GPO.DomainName # : ad.evotec.xyz
Enabled = $GPO.GpoStatus
Description = $GPO.Description
CreationDate = $GPO.CreationTime
ModificationTime = $GPO.ModificationTime
#Owner = $GPO.Owner # : EVOTEC\Domain Admins
#Trustee = $GPOPermission.Trustee # : Domain Admins
#TrusteeType = $GPOPermissionFormatted.TrusteeType # # : Group
Permission = $GPOPermission.Permission # : GpoEditDeleteModifySecurity
Inherited = $GPOPermission.Inherited # : False
Domain = $GPOPermission.Trustee.Domain #: EVOTEC
DistinguishedName = $GPOPermission.Trustee.DSPath #: CN = Domain Admins, CN = Users, DC = ad, DC = evotec, DC = xyz
Name = $GPOPermission.Trustee.Name #: Domain Admins
Sid = $GPOPermission.Trustee.Sid #: S - 1 - 5 - 21 - 853615985 - 2870445339 - 3163598659 - 512
SidType = $GPOPermission.Trustee.SidType #: Group
}
}
$SplittedOwner = $GPO.Owner.Split('\')
[PSCustomObject] @{
DisplayName = $GPO.DisplayName # : ALL | Enable RDP
GUID = $GPO.GUID
DomainName = $GPO.DomainName # : ad.evotec.xyz
#Owner = $GPO.Owner # : EVOTEC\Domain Admins
#Trustee = $GPOPermission.Trustee # : Domain Admins
#TrusteeType = $GPOPermissionFormatted.TrusteeType # # : Group
Enabled = $GPO.GpoStatus
Description = $GPO.Description
CreationDate = $GPO.CreationTime
ModificationTime = $GPO.ModificationTime
Permission = 'Owner' # : GpoEditDeleteModifySecurity
Inherited = $false # : False
Domain = $SplittedOwner[0] #: EVOTEC
DistinguishedName = '' #: CN = Domain Admins, CN = Users, DC = ad, DC = evotec, DC = xyz
Name = $SplittedOwner[1] #: Domain Admins
Sid = '' #: S - 1 - 5 - 21 - 853615985 - 2870445339 - 3163598659 - 512
SidType = '' #: Group
}
}
}
}