0 Pluspunkte 0 Minuspunkte

Wie kann ich den Befehl

gpupdate /force

auf allen Hosts in einer bestimmten OU in Active Directory ausführen?

import-module ActiveDirectory

$ou = "OU=Test,OU=DEF,OU=ABC,DC=dom,DC=local"

$computers = Get-ADComputer -Filter * -SearchBase "LDAP://$ou" | Select-Object -ExpandProperty Name

foreach ($computer in $computers) {
    
    Write-Host "Aktualisiere Gruppenrichtlinien auf $computer"
    
    Invoke-Command -ComputerName $computer -ScriptBlock { gpupdate /force }
    
    Write-Host ""

}
bezieht sich auf eine Antwort auf: GPUpdate auf allen Computern ausführen mit Powershell
von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Lass das "LDAP://" weg. Ändere die Zeile

$computers = Get-ADComputer -Filter * -SearchBase "LDAP://$ou" | Select-Object -ExpandProperty Name

zu

$computers = Get-ADComputer -Filter * -SearchBase $ou | Select-Object -ExpandProperty Name

von (706 Punkte)