Force domain-wide Group Policy update

by
published on

Since we moved our workstations to a Windows domain, the administration of those workstations has become significantly easier. One of the reasons for this are of course Group Policies. However, sometimes it's rather inconvenient to have to wait for the clients to update their GPOs from the server, which can take a while. Instead, you can force them to update straight from the server using a PowerShell script.

param(
[switch]$force,
[switch]$user
)

$target = "Computer"

if($user.IsPresent) {
$target = "User"
Write-Host "Targeting Users"
}

if($force.IsPresent) {
Write-Host "Force Parameter set"
Get-ADComputer -SearchBase "OU=Workstations,DC=908video,DC=local" -Properties MemberOf -Filter * |
%{Invoke-GPUpdate -Computer $_.Name -Force -Target $target -RandomDelayInMinute 0; "Refreshing host $_."}
}
else {
Get-ADComputer -SearchBase "OU=Workstations,DC=908video,DC=local" -Properties MemberOf -Filter * |
%{Invoke-GPUpdate -Computer $_.Name -Target $target -RandomDelayInMinute 0; "Refreshing host $_."}
}