mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-08-28 11:16:49 +00:00
Improved function
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
|
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
|
||||||
|
|
||||||
Get-GPOZaurrSysvol -VerifyDomainControllers -Verbose | Format-Table
|
Get-GPOZaurrSysvol -VerifyDomainControllers -Verbose | Format-Table *
|
||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
Description = 'Group Policy Eater'
|
Description = 'Group Policy Eater'
|
||||||
FunctionsToExport = 'Add-GPOPermission', 'Add-GPOZaurrPermission', 'Backup-GPOZaurr', 'Get-GPOZaurr', 'Get-GPOZaurrAD', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrLink', 'Get-GPOZaurrOwner', 'Get-GPOZaurrPassword', 'Get-GPOZaurrPermission', 'Get-GPOZaurrPermissionConsistency', 'Get-GPOZaurrSysvol', 'Get-GPOZaurrWMI', 'Invoke-GPOZaurrPermission', 'New-GPOZaurrWMI', 'Remove-GPOPermission', 'Remove-GPOZaurr', 'Remove-GPOZaurrPermission', 'Remove-GPOZaurrWMI', 'Repair-GPOZaurrPermissionConsistency', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles', 'Set-GPOOwner', 'Set-GPOZaurrOwner'
|
FunctionsToExport = 'Add-GPOPermission', 'Add-GPOZaurrPermission', 'Backup-GPOZaurr', 'Get-GPOZaurr', 'Get-GPOZaurrAD', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrLink', 'Get-GPOZaurrOwner', 'Get-GPOZaurrPassword', 'Get-GPOZaurrPermission', 'Get-GPOZaurrPermissionConsistency', 'Get-GPOZaurrSysvol', 'Get-GPOZaurrWMI', 'Invoke-GPOZaurrPermission', 'New-GPOZaurrWMI', 'Remove-GPOPermission', 'Remove-GPOZaurr', 'Remove-GPOZaurrPermission', 'Remove-GPOZaurrWMI', 'Repair-GPOZaurrPermissionConsistency', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles', 'Set-GPOOwner', 'Set-GPOZaurrOwner'
|
||||||
GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde'
|
GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde'
|
||||||
ModuleVersion = '0.0.28'
|
ModuleVersion = '0.0.29'
|
||||||
PowerShellVersion = '5.1'
|
PowerShellVersion = '5.1'
|
||||||
PrivateData = @{
|
PrivateData = @{
|
||||||
PSData = @{
|
PSData = @{
|
||||||
|
|||||||
@@ -39,9 +39,13 @@
|
|||||||
if ($null -ne $SysvolHash[$GPO.Id.GUID].FullName) {
|
if ($null -ne $SysvolHash[$GPO.Id.GUID].FullName) {
|
||||||
try {
|
try {
|
||||||
$ACL = Get-Acl -Path $SysvolHash[$GPO.Id.GUID].FullName -ErrorAction Stop
|
$ACL = Get-Acl -Path $SysvolHash[$GPO.Id.GUID].FullName -ErrorAction Stop
|
||||||
|
$Owner = $ACL.Owner
|
||||||
|
$ErrorMessage = ''
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Get-WinADGPOSysvolFolders - ACL reading failed for $($SysvolHash[$GPO.Id.GUID].FullName) with error: $($_.Exception.Message)"
|
Write-Warning "Get-GPOZaurrSysvol - ACL reading failed for $($SysvolHash[$GPO.Id.GUID].FullName) with error: $($_.Exception.Message)"
|
||||||
$ACL = $null
|
$ACL = $null
|
||||||
|
$Owner = ''
|
||||||
|
$ErrorMessage = $_.Exception.Message
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ACL = $null
|
$ACL = $null
|
||||||
@@ -58,7 +62,7 @@
|
|||||||
SysvolServer = $Server
|
SysvolServer = $Server
|
||||||
SysvolStatus = $SysVolStatus
|
SysvolStatus = $SysVolStatus
|
||||||
Owner = $GPO.Owner
|
Owner = $GPO.Owner
|
||||||
FileOwner = $ACL.Owner
|
FileOwner = $Owner
|
||||||
Id = $GPO.Id.Guid
|
Id = $GPO.Id.Guid
|
||||||
GpoStatus = $GPO.GpoStatus
|
GpoStatus = $GPO.GpoStatus
|
||||||
Description = $GPO.Description
|
Description = $GPO.Description
|
||||||
@@ -67,17 +71,22 @@
|
|||||||
UserVersion = $GPO.UserVersion
|
UserVersion = $GPO.UserVersion
|
||||||
ComputerVersion = $GPO.ComputerVersion
|
ComputerVersion = $GPO.ComputerVersion
|
||||||
WmiFilter = $GPO.WmiFilter
|
WmiFilter = $GPO.WmiFilter
|
||||||
|
Error = $ErrorMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Now we need to list thru Sysvol files and fine those that do not exists as GPO and create dummy GPO objects to show orphaned gpos
|
# Now we need to list thru Sysvol files and fine those that do not exists as GPO and create dummy GPO objects to show orphaned gpos
|
||||||
foreach ($_ in $Differences.Keys) {
|
foreach ($_ in $Differences.Keys) {
|
||||||
if ($Differences[$_] -eq 'Orphaned GPO') {
|
if ($Differences[$_] -eq 'Orphaned GPO') {
|
||||||
if ($SysvolHash[$_].BaseName -notcontains 'PolicyDefinitions') {
|
if ($SysvolHash[$_].BaseName -notcontains 'PolicyDefinitions') {
|
||||||
|
try {
|
||||||
if ($null -ne $SysvolHash[$_].FullName) {
|
$ACL = Get-Acl -Path $SysvolHash[$_].FullName -ErrorAction Stop
|
||||||
$ACL = Get-Acl -Path $SysvolHash[$_].FullName -ErrorAction SilentlyContinue
|
$Owner = $ACL.Owner
|
||||||
} else {
|
$ErrorMessage = ''
|
||||||
|
} catch {
|
||||||
|
Write-Warning "Get-GPOZaurrSysvol - ACL reading failed for $($SysvolHash[$_].FullName) with error: $($_.Exception.Message)"
|
||||||
$ACL = $null
|
$ACL = $null
|
||||||
|
$Owner = $null
|
||||||
|
$ErrorMessage = $_.Exception.Message
|
||||||
}
|
}
|
||||||
|
|
||||||
[PSCustomObject] @{
|
[PSCustomObject] @{
|
||||||
@@ -86,8 +95,8 @@
|
|||||||
DomainName = $Domain
|
DomainName = $Domain
|
||||||
SysvolServer = $Server
|
SysvolServer = $Server
|
||||||
SysvolStatus = $Differences[$GPO.Id.Guid]
|
SysvolStatus = $Differences[$GPO.Id.Guid]
|
||||||
Owner = $ACL.Owner
|
Owner = ''
|
||||||
FileOwner = $ACL.Owner
|
FileOwner = $Owner
|
||||||
Id = $_
|
Id = $_
|
||||||
GpoStatus = 'Orphaned'
|
GpoStatus = 'Orphaned'
|
||||||
Description = $null
|
Description = $null
|
||||||
@@ -96,6 +105,7 @@
|
|||||||
UserVersion = $null
|
UserVersion = $null
|
||||||
ComputerVersion = $null
|
ComputerVersion = $null
|
||||||
WmiFilter = $null
|
WmiFilter = $null
|
||||||
|
Error = $ErrorMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user