mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-07-26 11:49:17 +00:00
Update for Invoke-GPOZaurrSupport
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
param(
|
||||
[System.Xml.XmlElement]$Content,
|
||||
[string] $ResultsType,
|
||||
[Microsoft.GroupPolicy.GPRsop] $ResultantSetPolicy,
|
||||
# [Microsoft.GroupPolicy.GPRsop] $ResultantSetPolicy,
|
||||
[string] $Splitter = [System.Environment]::NewLine
|
||||
)
|
||||
$GPOPrimary = [ordered] @{
|
||||
Summary = $null
|
||||
SummaryDetails = [System.Collections.Generic.List[PSCustomObject]]::new()
|
||||
SummaryDownload = $null
|
||||
ResultantSetPolicy = $ResultantSetPolicy
|
||||
#ResultantSetPolicy = $ResultantSetPolicy
|
||||
|
||||
GroupPolicies = $null
|
||||
GroupPoliciesLinks = $null
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
function New-GPOZaurrReportConsole {
|
||||
[cmdletBinding()]
|
||||
param(
|
||||
[System.Collections.IDictionary] $Results
|
||||
[System.Collections.IDictionary] $Results,
|
||||
[string] $ComputerName
|
||||
)
|
||||
Begin {
|
||||
$GPODeny = @{
|
||||
@@ -20,26 +21,40 @@
|
||||
$UserWhereApplied = ($Results.UserResults.GroupPolicies | Sort-Object -Property Name).Where( { $_.Status -eq 'Applied' }, 'split')
|
||||
}
|
||||
Process {
|
||||
Write-Color -Text 'Computer Settings' -Color White -LinesBefore 1
|
||||
Write-Color -Text '[>] Last time Group Policy was applied: ', $Results.ComputerResults.Summary.ReadTime @WriteSummary
|
||||
Write-Color -Text '[>] Computer Name: ', $Results.ComputerResults.Summary.ComputerName @WriteSummary
|
||||
Write-Color -Text '[>] Domain Name: ', $Results.ComputerResults.Summary.DomainName @WriteSummary
|
||||
Write-Color -Text '[>] Organizational Unit: ', $Results.ComputerResults.Summary.OrganizationalUnit @WriteSummary
|
||||
Write-Color -Text '[>] Site: ', $Results.ComputerResults.Summary.Site @WriteSummary
|
||||
Write-Color -Text '[>] GPO Types: ', ($Results.ComputerResults.Summary.GPOTypes -replace [System.Environment]::NewLine, ', ') @WriteSummary
|
||||
Write-Color -Text '[>] Slow link: ', ($Results.ComputerResults.Summary.SlowLink) @WriteSummary
|
||||
if ($Results.ComputerResults) {
|
||||
Write-Color -Text 'Computer Settings' -Color Yellow -LinesBefore 1
|
||||
Write-Color -Text '[>] Last time Group Policy was applied: ', $Results.ComputerResults.Summary.ReadTime @WriteSummary
|
||||
Write-Color -Text '[>] Computer Name: ', $Results.ComputerResults.Summary.ComputerName @WriteSummary
|
||||
Write-Color -Text '[>] Domain Name: ', $Results.ComputerResults.Summary.DomainName @WriteSummary
|
||||
Write-Color -Text '[>] Organizational Unit: ', $Results.ComputerResults.Summary.OrganizationalUnit @WriteSummary
|
||||
Write-Color -Text '[>] Site: ', $Results.ComputerResults.Summary.Site @WriteSummary
|
||||
Write-Color -Text '[>] GPO Types: ', ($Results.ComputerResults.Summary.GPOTypes -replace [System.Environment]::NewLine, ', ') @WriteSummary
|
||||
Write-Color -Text '[>] Slow link: ', ($Results.ComputerResults.Summary.SlowLink) @WriteSummary
|
||||
|
||||
Write-Color -Text 'Applied Group Policy Objects' -StartSpaces 3 -LinesBefore 1
|
||||
foreach ($GPO in $ComputerWhereApplied[0]) {
|
||||
Write-Color -Text '[+] [', $GPO.DomainName, '] ', $GPO.Name @GPOSuccess
|
||||
}
|
||||
Write-Color -Text 'Applied Group Policy Objects' -StartSpaces 3 -LinesBefore 1
|
||||
foreach ($GPO in $ComputerWhereApplied[0]) {
|
||||
Write-Color -Text '[+] [', $GPO.DomainName, '] ', $GPO.Name @GPOSuccess
|
||||
}
|
||||
|
||||
Write-Color -Text 'Denied Group Policy Objects' -StartSpaces 3
|
||||
foreach ($GPO in $ComputerWhereApplied[1]) {
|
||||
Write-Color -Text '[-] [', $GPO.DomainName, '] ', $GPO.Name @GPODeny
|
||||
Write-Color -Text 'Denied Group Policy Objects' -StartSpaces 3
|
||||
foreach ($GPO in $ComputerWhereApplied[1]) {
|
||||
Write-Color -Text '[-] [', $GPO.DomainName, '] ', $GPO.Name @GPODeny
|
||||
}
|
||||
} else {
|
||||
Write-Color -Text 'Computer Settings' -Color Yellow -LinesBefore 1
|
||||
Write-Color -Text '[>] Last time Group Policy was applied: ', 'Unable to get? No administrative permission?' @WriteSummary
|
||||
Write-Color -Text '[>] Computer Name: ', $ComputerName @WriteSummary
|
||||
}
|
||||
|
||||
Write-Color -Text 'User Settings' -Color Yellow -LinesBefore 1
|
||||
Write-Color -Text '[>] Last time Group Policy was applied: ', $Results.UserResults.Summary.ReadTime @WriteSummary
|
||||
Write-Color -Text '[>] Computer Name: ', $Results.UserResults.Summary.ComputerName @WriteSummary
|
||||
Write-Color -Text '[>] Domain Name: ', $Results.UserResults.Summary.DomainName @WriteSummary
|
||||
Write-Color -Text '[>] Organizational Unit: ', $Results.UserResults.Summary.OrganizationalUnit @WriteSummary
|
||||
Write-Color -Text '[>] Site: ', $Results.UserResults.Summary.Site @WriteSummary
|
||||
Write-Color -Text '[>] GPO Types: ', ($Results.UserResults.Summary.GPOTypes -replace [System.Environment]::NewLine, ', ') @WriteSummary
|
||||
Write-Color -Text '[>] Slow link: ', ($Results.UserResults.Summary.SlowLink) @WriteSummary
|
||||
|
||||
Write-Color -Text 'Applied Group Policy Objects' -StartSpaces 3
|
||||
foreach ($GPO in $UserWhereApplied[0] ) {
|
||||
Write-Color -Text '[+] [', $GPO.DomainName, '] ', $GPO.Name @GPOSuccess
|
||||
|
||||
@@ -23,43 +23,42 @@ function New-GPOZaurrReportHTML {
|
||||
New-HTML -TitleText "Group Policy Report - $ComputerName" {
|
||||
#New-HTMLTabOptions -SlimTabs -Transition -LinearGradient -SelectorColor Akaroa
|
||||
New-HTMLTableOption -DataStore JavaScript -BoolAsString
|
||||
New-HTMLSectionStyle -BorderRadius 0px -HeaderBackGroundColor Grey -RemoveShadow
|
||||
New-HTMLPanelStyle -BorderRadius 0px
|
||||
New-HTMLTabOptions -SlimTabs `
|
||||
-BorderBottomStyleActive solid -BorderBottomColorActive LightSkyBlue -BackgroundColorActive none `
|
||||
-TextColorActive Black -Align left -BorderRadius 0px -RemoveShadow -TextColor Grey -TextTransform capitalize
|
||||
New-HTMLTab -Name 'Information' {
|
||||
New-HTMLTable -DataTable $Support.ResultantSetPolicy -HideFooter -Transpose
|
||||
|
||||
New-HTMLSection {
|
||||
New-HTMLSection {
|
||||
#New-HTMLTable -DataTable $Support.ResultantSetPolicy -HideFooter -Transpose
|
||||
New-HTMLSection -HeaderText 'General Information' {
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.Time -Filtering -Transpose {
|
||||
New-TableHeader -Names 'Name', 'Value' -Title 'Time Information'
|
||||
}
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.BIOS -Filtering -Transpose
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.BIOS -Filtering -Transpose {
|
||||
New-TableHeader -Names 'Name', 'Value' -Title 'BIOS Information'
|
||||
}
|
||||
}
|
||||
New-HTMLContainer {
|
||||
New-HTMLSection {
|
||||
New-HTMLSection -HeaderText 'CPU Information' {
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.CPU -Filtering
|
||||
}
|
||||
New-HTMLSection {
|
||||
New-HTMLSection -HeaderText 'RAM Information' {
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.RAM -Filtering
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
New-HTMLSection {
|
||||
New-HTMLSection -HeaderText 'Operating System Information' {
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.OperatingSystem -Filtering
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.System -Filtering
|
||||
}
|
||||
New-HTMLSection {
|
||||
New-HTMLSection -HeaderText 'Disk Information' {
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.Disk -Filtering
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.DiskLogical -Filtering
|
||||
}
|
||||
New-HTMLSection {
|
||||
New-HTMLSection -HeaderText 'Services Information' {
|
||||
New-HTMLTable -DataTable $Support.ComputerInformation.Services -Filtering
|
||||
}
|
||||
New-HTMLSection {
|
||||
|
||||
}
|
||||
}
|
||||
foreach ($Key in $Support.Keys) {
|
||||
if ($Key -in 'ResultantSetPolicy', 'ComputerInformation') {
|
||||
@@ -81,9 +80,9 @@ function New-GPOZaurrReportHTML {
|
||||
New-HTMLTable -DataTable $Support.$Key.SummaryDownload -HideFooter
|
||||
}
|
||||
#>
|
||||
New-HTMLSection -HeaderText 'Resultant Set Policy' {
|
||||
New-HTMLTable -DataTable $Support.$Key.ResultantSetPolicy -HideFooter
|
||||
}
|
||||
#New-HTMLSection -HeaderText 'Resultant Set Policy' {
|
||||
# New-HTMLTable -DataTable $Support.$Key.ResultantSetPolicy -HideFooter
|
||||
#}
|
||||
}
|
||||
New-HTMLTab -Name 'Group Policies' {
|
||||
New-HTMLSection -Invisible {
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
[string] $Path,
|
||||
[string] $Splitter = [System.Environment]::NewLine,
|
||||
[switch] $PreventShow,
|
||||
[switch] $Offline,
|
||||
[switch] $ForceGPResult
|
||||
[switch] $Offline #,
|
||||
# [switch] $ForceGPResult
|
||||
)
|
||||
# if user didn't choose anything, lets run as currently logged in user locally
|
||||
if (-not $UserName -and -not $ComputerName) {
|
||||
@@ -54,39 +54,43 @@
|
||||
if ($UserName) {
|
||||
$SplatPolicy['User'] = $UserName
|
||||
}
|
||||
if ($Command -and -not $ForceGPResult) {
|
||||
try {
|
||||
#Write-Verbose "Request-GPOZaurr - ComputerName: $($SplatPolicy['Computer']) UserName: $($SplatPolicy['User'])"
|
||||
$ResultantSetPolicy = Get-GPResultantSetOfPolicy @SplatPolicy -ErrorAction Stop
|
||||
} catch {
|
||||
if ($_.Exception.Message -eq 'Exception from HRESULT: 0x80041003') {
|
||||
Write-Warning "Request-GPOZaurr - Are you running as admin? $($_.Exception.Message)"
|
||||
return
|
||||
} else {
|
||||
$ErrorMessage = $($_.Exception.Message).Replace([Environment]::NewLine, ' ')
|
||||
Write-Warning "Request-GPOZaurr - Error: $ErrorMessage"
|
||||
return
|
||||
}
|
||||
|
||||
$SplatPolicy['TempXmlPath'] = [io.path]::GetTempFileName().Replace('.tmp', ".xml")
|
||||
# Originally planned to use Get-GPResultantSetOfPolicy but it only works with administrative rights
|
||||
# if ($Command -and -not $ForceGPResult) {
|
||||
# try {
|
||||
# Write-Verbose "Invoke-GPOZaurrSupport - ComputerName: $($SplatPolicy['Computer']), UserName: $($SplatPolicy['User']), ReportType: $($SplatPolicy['ReportType']), Path: $($SplatPolicy['Path'])"
|
||||
# $ResultantSetPolicy = Get-GPResultantSetOfPolicy @SplatPolicy -ErrorAction Stop
|
||||
# } catch {
|
||||
# if ($_.Exception.Message -eq 'Exception from HRESULT: 0x80041003') {
|
||||
# Write-Warning "Invoke-GPOZaurrSupport - Are you running as admin? $($_.Exception.Message)"
|
||||
# return
|
||||
# } else {
|
||||
# $ErrorMessage = $($_.Exception.Message).Replace([Environment]::NewLine, ' ')
|
||||
# Write-Warning "Invoke-GPOZaurrSupport - Error: $ErrorMessage"
|
||||
# return
|
||||
# }
|
||||
# }
|
||||
# } else {
|
||||
$Arguments = @(
|
||||
if ($SplatPolicy['Computer']) {
|
||||
"/S $ComputerName"
|
||||
}
|
||||
} else {
|
||||
$Arguments = @(
|
||||
if ($SplatPolicy['Computer']) {
|
||||
"/S $ComputerName"
|
||||
}
|
||||
if ($SplatPolicy['User']) {
|
||||
"/USER $($SplatPolicy['User'])"
|
||||
}
|
||||
if ($SplatPolicy['ReportType'] -eq 'HTML') {
|
||||
'/H'
|
||||
} elseif ($SplatPolicy['ReportType'] -eq 'XML') {
|
||||
'/X'
|
||||
}
|
||||
if ($SplatPolicy['User']) {
|
||||
"/USER $($SplatPolicy['User'])"
|
||||
}
|
||||
if ($SplatPolicy['ReportType'] -eq 'HTML') {
|
||||
'/H'
|
||||
$SplatPolicy['Path']
|
||||
"/F"
|
||||
)
|
||||
Write-Verbose "Invoke-GPOZaurrSupport - GPResult Arguments: $Arguments"
|
||||
Start-Process -NoNewWindow -FilePath 'gpresult' -ArgumentList $Arguments -Wait
|
||||
}
|
||||
} elseif ($SplatPolicy['ReportType'] -eq 'XML') {
|
||||
'/X'
|
||||
$SplatPolicy['TempXmlPath']
|
||||
}
|
||||
"/F"
|
||||
)
|
||||
Write-Verbose "Invoke-GPOZaurrSupport - GPResult Arguments: $Arguments"
|
||||
Start-Process -NoNewWindow -FilePath 'gpresult' -ArgumentList $Arguments -Wait
|
||||
#}
|
||||
if ($Type -eq 'NativeHTML') {
|
||||
if (-not $PreventShow) {
|
||||
Write-Verbose "Invoke-GPOZaurrSupport - Opening up file $($SplatPolicy['Path'])"
|
||||
@@ -95,39 +99,58 @@
|
||||
return
|
||||
}
|
||||
# Loads created XML by resultant Output
|
||||
if ($SplatPolicy.Path -and (Test-Path -LiteralPath $SplatPolicy.Path)) {
|
||||
[xml] $PolicyContent = Get-Content -LiteralPath $SplatPolicy.Path
|
||||
if ($SplatPolicy.TempXmlPath -and (Test-Path -LiteralPath $SplatPolicy.TempXmlPath)) {
|
||||
[xml] $PolicyContent = Get-Content -LiteralPath $SplatPolicy.TempXmlPath
|
||||
if ($PolicyContent) {
|
||||
# lets remove temporary XML file
|
||||
Remove-Item -LiteralPath $SplatPolicy.Path
|
||||
Remove-Item -LiteralPath $SplatPolicy.TempXmlPath
|
||||
} else {
|
||||
Write-Warning "Request-GPOZaurr - Couldn't load XML file from drive $($SplatPolicy.Path). Terminating."
|
||||
Write-Warning "Invoke-GPOZaurrSupport - Couldn't load XML file from drive $($SplatPolicy.TempXmlPath). Terminating."
|
||||
return
|
||||
}
|
||||
} else {
|
||||
Write-Warning "Request-GPOZaurr - Couldn't find XML file on drive $($SplatPolicy.Path). Terminating."
|
||||
Write-Warning "Invoke-GPOZaurrSupport - Couldn't find XML file on drive $($SplatPolicy.TempXmlPath). Terminating."
|
||||
return
|
||||
}
|
||||
if ($ComputerName) {
|
||||
if (-not $PolicyContent.Rsop.'ComputerResults'.EventsDetails) {
|
||||
Write-Warning "Request-GPOZaurr - Windows Events for Group Policy are missing. Amount of data will be limited. Firewall issue?"
|
||||
Write-Warning "Invoke-GPOZaurrSupport - Windows Events for Group Policy are missing. Amount of data will be limited. Firewall issue?"
|
||||
}
|
||||
}
|
||||
if (-not $ComputerName) {
|
||||
# Ok, user haven't given computername, and we're not admin, so RSOP won't be there, but we will use $ComputerName further down to get additional data, even without administrative rights
|
||||
# Also for display purposes
|
||||
$ComputerName = $Env:COMPUTERNAME
|
||||
}
|
||||
|
||||
if ($Type -eq 'XML') {
|
||||
$PolicyContent.Rsop
|
||||
} else {
|
||||
if ($VerbosePreference -ne 'SilentlyContinue') {
|
||||
$Verbose = $true
|
||||
} else {
|
||||
$Verbose = $false
|
||||
}
|
||||
$Output = [ordered] @{
|
||||
ComputerInformation = Get-Computer -ComputerName $ComputerName
|
||||
ResultantSetPolicy = $ResultantSetPolicy
|
||||
ComputerInformation = Get-Computer -ComputerName $ComputerName -Verbose:$Verbose
|
||||
#ResultantSetPolicy = $ResultantSetPolicy
|
||||
|
||||
<# ResultantSetPolicy = $ResultantSetPolicy
|
||||
RunspaceId : 5a4931ea-915e-42d3-80d8-6a86b16eb271
|
||||
RsopMode : Logging
|
||||
Namespace : \\EVOSPEED\Root\Rsop\NS103F4892_39E9_42B8_B0FF_E438EC0796B5
|
||||
LoggingComputer : EVOSPEED
|
||||
LoggingUser : EVOTEC\przemyslaw.klys
|
||||
LoggingMode : UserAndComputer
|
||||
#>
|
||||
}
|
||||
if ($PolicyContent.Rsop.ComputerResults) {
|
||||
$Output.ComputerResults = ConvertFrom-XMLRSOP -Content $PolicyContent.Rsop -ResultantSetPolicy $ResultantSetPolicy -ResultsType 'ComputerResults' -Splitter $Splitter
|
||||
$Output.ComputerResults = ConvertFrom-XMLRSOP -Content $PolicyContent.Rsop -ResultsType 'ComputerResults' -Splitter $Splitter
|
||||
}
|
||||
if ($PolicyContent.Rsop.UserResults) {
|
||||
$Output.UserResults = ConvertFrom-XMLRSOP -Content $PolicyContent.Rsop -ResultantSetPolicy $ResultantSetPolicy -ResultsType 'UserResults' -Splitter $Splitter
|
||||
$Output.UserResults = ConvertFrom-XMLRSOP -Content $PolicyContent.Rsop -ResultsType 'UserResults' -Splitter $Splitter
|
||||
}
|
||||
|
||||
New-GPOZaurrReportConsole -Results $Output
|
||||
New-GPOZaurrReportConsole -Results $Output -ComputerName $ComputerName
|
||||
if ($Type -contains 'Object') {
|
||||
$Output
|
||||
} elseif ($Type -contains 'HTML') {
|
||||
|
||||
Reference in New Issue
Block a user