Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Find Orphaned GPOs In SYSVOL health check #107

Closed
rebelinux opened this issue Jun 21, 2023 · 2 comments · Fixed by #111
Closed

Add Find Orphaned GPOs In SYSVOL health check #107

rebelinux opened this issue Jun 21, 2023 · 2 comments · Fixed by #111

Comments

@rebelinux
Copy link
Collaborator

Adam Bertram

function Get-OrphanedGPO {
    
    [CmdletBinding()]
    param (
        [Parameter(Mandatory)]
        [string]$ForestName
    )
    try {
        ## Find all domains in the forest
        $domains = Get-AdForest -Identity $ForestName | Select-Object -ExpandProperty Domains
        $gpoGuids = @()
        $sysvolGuids = @()
        foreach ($domain in $Domains) {
            $gpoGuids += Get-GPO -All -Domain $domain | Select-Object @{ n='GUID'; e = {$_.Id.ToString()}} | Select-Object -ExpandProperty GUID
            foreach ($guid in $gpoGuids) {
                $polPath = "\\$domain\SYSVOL\$domain\Policies"
                $polFolders = Get-ChildItem $polPath -Exclude 'PolicyDefinitions' | Select-Object -ExpandProperty name
                foreach ($folder in $polFolders) {
                    $sysvolGuids += $folder -replace '{|}'
                }
            }
        }
        Compare-Object -ReferenceObject $sysvolGuids -DifferenceObject $gpoGuids | Select-Object -ExpandProperty InputObject
    } catch {
        $PSCmdlet.ThrowTerminatingError($_)
    }
}
@rebelinux
Copy link
Collaborator Author

Image

@rebelinux
Copy link
Collaborator Author

Added more relevant information to the table

Image

rebelinux added a commit to rebelinux/AsBuiltReport.Microsoft.AD that referenced this issue Jun 21, 2023
@rebelinux rebelinux mentioned this issue Jun 23, 2023
7 tasks
@rebelinux rebelinux mentioned this issue Jun 23, 2023
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant