← script library

Force a Group Policy Update with PowerShell

Windows Server RolesAugust 17, 2026

Runs gpupdate /force and then parses gpresult to report when policy was last applied and which GPOs are actually in effect. Applying policy is the easy half; showing that the expected GPO arrived is the half that ends the argument about whether the change worked.

powershell
# Force Group Policy Update
# Single use case: gpupdate /force and report the applied policy state
#-----------------------------------------------------------------

function Write-Log {
    param($Message)
    Write-Host "<WRITE-LOG = `"*$Message*`">"
}

Write-Log "Running gpupdate /force..."
$out = & gpupdate.exe /force 2>&1 | Out-String

if ($out -match "Computer Policy update has completed successfully") {
    Write-Log "Computer policy updated successfully."
} else {
    Write-Log "Computer policy update output: $((($out -split "`n") | Where-Object { $_.Trim() } | Select-Object -First 3) -join ' | ')"
}

# Report last policy application from the OS
$rsop = & gpresult.exe /r /scope:computer 2>&1 | Out-String
$applied = ($rsop -split "`n" | Select-String "Last time Group Policy was applied" | Select-Object -First 1)
if ($applied) { Write-Log $applied.ToString().Trim() }

$gpos = $false
$lines = $rsop -split "`n"
for ($i = 0; $i -lt $lines.Count; $i++) {
    if ($lines[$i] -match "Applied Group Policy Objects") {
        Write-Log "================ Applied GPOs ================"
        for ($j = $i + 2; $j -lt $lines.Count; $j++) {
            $entry = $lines[$j].Trim()
            if ([string]::IsNullOrWhiteSpace($entry) -or $entry.StartsWith("The following")) { break }
            if ($entry -match "^-+$") { continue }
            Write-Log " - $entry"
            $gpos = $true
        }
        break
    }
}
if (-not $gpos) { Write-Log "Could not parse applied GPO list from gpresult." }

Write-Log "Group policy update complete."

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.