mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-09-01 05:07:57 +00:00
Remove Orphaned Sysvol Folders
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
|
||||||
|
|
||||||
|
Remove-GPOZaurrOrphanedSysvolFolders -Verbose -WhatIf
|
||||||
+2
-2
@@ -5,9 +5,9 @@
|
|||||||
CompatiblePSEditions = 'Desktop'
|
CompatiblePSEditions = 'Desktop'
|
||||||
Copyright = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.'
|
Copyright = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.'
|
||||||
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-WMIFilter', 'Get-GPOZaurrWMI', 'Invoke-GPOZaurrPermission', 'New-GPOZaurrWMI', 'Remove-GPOPermission', 'Remove-GPOZaurr', 'Remove-GPOZaurrOrphanedSysvolFolders', '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.30'
|
ModuleVersion = '0.0.31'
|
||||||
PowerShellVersion = '5.1'
|
PowerShellVersion = '5.1'
|
||||||
PrivateData = @{
|
PrivateData = @{
|
||||||
PSData = @{
|
PSData = @{
|
||||||
|
|||||||
@@ -21,13 +21,17 @@
|
|||||||
Write-Warning "Get-GPOZaurrSysvol - Couldn't get GPOs from $Domain. Error: $($_.Exception.Message)"
|
Write-Warning "Get-GPOZaurrSysvol - Couldn't get GPOs from $Domain. Error: $($_.Exception.Message)"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (-not $VerifyDomainControllers) {
|
if ($GPOs.Count -ge 2) {
|
||||||
Test-SysVolFolders -GPOs $GPOs -Server $Domain -Domain $Domain
|
if (-not $VerifyDomainControllers) {
|
||||||
} else {
|
Test-SysVolFolders -GPOs $GPOs -Server $Domain -Domain $Domain
|
||||||
foreach ($Server in $ForestInformation['DomainDomainControllers']["$Domain"]) {
|
} else {
|
||||||
Write-Verbose "Get-WinADGPOSysvolFolders - Processing $Domain \ $($Server.HostName.Trim())"
|
foreach ($Server in $ForestInformation['DomainDomainControllers']["$Domain"]) {
|
||||||
Test-SysVolFolders -GPOs $GPOs -Server $Server.Hostname -Domain $Domain
|
Write-Verbose "Get-GPOZaurrSysvol - Processing $Domain \ $($Server.HostName.Trim())"
|
||||||
|
Test-SysVolFolders -GPOs $GPOs -Server $Server.Hostname -Domain $Domain
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Write-Warning "Get-GPOZaurrSysvol - GPO count for $Domain is less then 2. This is not expected for fully functioning domain. Skipping processing SYSVOL folder."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
function Remove-GPOZaurrOrphanedSysvolFolders {
|
||||||
|
[cmdletBinding(SupportsShouldProcess)]
|
||||||
|
param(
|
||||||
|
[int] $LimitProcessing = [int32]::MaxValue
|
||||||
|
)
|
||||||
|
Get-GPOZaurrSysvol | Where-Object {
|
||||||
|
if ($_.Status -eq 'Orphaned GPO') {
|
||||||
|
$_
|
||||||
|
}
|
||||||
|
} | Select-Object | Select-Object -First $LimitProcessing | ForEach-Object {
|
||||||
|
Remove-Item -Recurse -Force -LiteralPath $_.Path
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user