Voici quelques commandes Powershell pour trouver les OU dont l’héritage est bloqué:
1 2 3 | $GPOBlocked = Get-ADOrganizationalUnit -SearchBase "DC=LAB,DC=Org" -Filter * | Get-GPInheritance | Where-Object { $_ .GpoInheritanceBlocked} $GPOBlocked .count $GPOBlocked | Select Name,Path |
Le DistinguishedName (Path) n’est pas toujours agréable à lire je fais donc une conversion en CanonicalName, ensuite vous pouvez afficher les données à l’écran ou les écrire dans un fichier:
1 2 3 4 5 6 | $GPOBlocked | ForEach-Object { $Name = $_ . "Name" $Path = $_ . "Path" $CanonicalName = Get-ADOrganizationalUnit -Filter {DistinguishedName -like $Path } -Properties CanonicalName | Select-Object -ExpandProperty CanonicalName Write-Output "$Name; $CanonicalName" | Add-Content C:\Temp\GpoInheritanceBlocked.txt } |
0 commentaires