This commit is contained in:
Przemyslaw Klys
2020-12-04 10:20:20 +01:00
parent a3a1fd6ea7
commit 39d781d899
3 changed files with 45 additions and 25 deletions
+5 -5
View File
@@ -1,6 +1,7 @@
function Get-GPOZaurr {
[cmdletBinding()]
param(
[scriptblock] $ExcludeGroupPolicies,
[string] $GPOName,
[alias('GUID', 'GPOID')][string] $GPOGuid,
@@ -10,8 +11,6 @@
[System.Collections.IDictionary] $ExtendedForestInformation,
[string[]] $GPOPath,
[Array] $ExcludeGroupPolicies,
[switch] $PermissionsOnly,
[switch] $OwnerOnly,
[switch] $Limited,
@@ -28,13 +27,14 @@
}
$ExcludeGPO = [ordered] @{}
if ($ExcludeGroupPolicies) {
foreach ($GroupPolicy in $ExcludeGroupPolicies) {
$ExExecution = Invoke-Command -ScriptBlock $ExcludeGroupPolicies
foreach ($GroupPolicy in $ExExecution) {
if ($GroupPolicy -is [string]) {
$ExcludeGPO[$GroupPolicy] = $true
} elseif ($GroupPolicy -is [System.Collections.IDictionary] -and $GroupPolicy.Name -and $GroupPolicy.DomainName) {
} elseif ($GroupPolicy.Name -and $GroupPolicy.DomainName) {
$PolicyName = -join ($GroupPolicy.DomainName, $GroupPolicy.Name)
$ExcludeGPO[$PolicyName] = $true
} elseif ($GroupPolicy -is [System.Collections.IDictionary] -and $GroupPolicy.Name) {
} elseif ($GroupPolicy.Name) {
$ExcludeGPO[$GroupPolicy.Name] = $true
} else {
Write-Warning "Get-GPOZaurr - Exclusion takes only Group Policy Name as string, or as hashtable with domain name @{ Name = 'Group Policy Name'; DomainName = 'Domain' }."
+29 -15
View File
@@ -2,12 +2,14 @@
[alias('Show-GPOZaurr', 'Show-GPO')]
[cmdletBinding()]
param(
[scriptblock] $Extension,
[scriptblock] $Exclusions,
[string] $FilePath,
[string[]] $Type,
[switch] $PassThru,
[switch] $HideHTML,
[switch] $HideSteps,
[switch] $HideErrors,
[switch] $HideWarnings,
[alias('ForestName')][string] $Forest,
[string[]] $ExcludeDomains,
[alias('Domain', 'Domains')][string[]] $IncludeDomains
@@ -16,6 +18,11 @@
$Script:Reporting = [ordered] @{}
$Script:Reporting['Version'] = Get-GitHubVersion -Cmdlet 'Invoke-GPOZaurr' -RepositoryOwner 'evotecit' -RepositoryName 'GPOZaurr'
$Script:Reporting['Settings'] = @{
HideErrors = $HideErrors.IsPresent
HideWarnings = $HideWarnings.IsPresent
HideSteps = $HideSteps.IsPresent
}
Write-Color '[i]', "[GPOZaurr] ", 'Version', ' [Informative] ', $Script:Reporting['Version'] -Color Yellow, DarkGray, Yellow, DarkGray, Magenta
# Verify requested types are supported
@@ -43,6 +50,7 @@
Write-Color '[i]', "[GPOZaurr] ", 'Domain Information', ' [Informative] ', "Excluded Domains: ", $DisplayExcludedDomains -Color Yellow, DarkGray, Yellow, DarkGray, Yellow, Magenta
# Exclusions support, converts ScriptBlock into list of GPOs
<#
$Exclusions = [ordered]@{}
if ($Extension) {
$Exclusions['All'] = [System.Collections.Generic.List[PSCustomObject]]::new()
@@ -60,6 +68,7 @@
}
}
}
#>
# Lets make sure we only enable those types which are requestd by user
if ($Type) {
@@ -86,7 +95,8 @@
Variables = Copy-Dictionary -Dictionary $Script:GPOConfiguration[$T]['Variables']
}
if ($Exclusions) {
$Script:Reporting[$T]['Exclusions'] = $Extension
$Script:Reporting[$T]['ExclusionsCode'] = $Exclusions
$Script:Reporting[$T]['Exclusions'] = & $Exclusions
}
$TimeLogGPOList = Start-TimeLog
@@ -101,20 +111,24 @@
}
Invoke-Command -ScriptBlock $Script:GPOConfiguration[$T]['Processing']
$Script:Reporting[$T]['WarningsAndErrors'] = @(
foreach ($War in $CommandWarnings) {
[PSCustomObject] @{
Type = 'Warning'
Comment = $War
Reason = ''
TargetName = ''
if (-not $HideWarnings) {
foreach ($War in $CommandWarnings) {
[PSCustomObject] @{
Type = 'Warning'
Comment = $War
Reason = ''
TargetName = ''
}
}
}
foreach ($Err in $CommandErrors) {
[PSCustomObject] @{
Type = 'Error'
Comment = $Err
Reason = $Err.CategoryInfo.Reason
TargetName = $Err.CategoryInfo.TargetName
if (-not $HideErrors) {
foreach ($Err in $CommandErrors) {
[PSCustomObject] @{
Type = 'Error'
Comment = $Err
Reason = $Err.CategoryInfo.Reason
TargetName = $Err.CategoryInfo.TargetName
}
}
}
)
+11 -5
View File
@@ -5,10 +5,16 @@
[string] $Name,
[string] $DomaiName
)
@{
Type = 'Exclusion'
ReportType = $Type
Name = $Name
DomainName = $DomaiName
if ($Type) {
[PSCustomObject] @{
Type = $Type
Name = $Name
DomainName = $DomaiName
}
} else {
[PSCustomObject] @{
Name = $Name
DomainName = $DomaiName
}
}
}