echo [%DATE% %TIME%] Starting GPUpdate >> "%LOGFILE%"
if ($ComputerName -eq $env:COMPUTERNAME) Write-Host "Running gpupdate locally..." -ForegroundColor Cyan $params = if ($Force) "/force" else "" $result = Start-Process -Wait -NoNewWindow -FilePath "gpupdate.exe" -ArgumentList $params -PassThru $exitCode = $result.ExitCode else Write-Host "Running gpupdate on $ComputerName..." -ForegroundColor Cyan $scriptBlock = param($forceFlag) if ($forceFlag) gpupdate /force else gpupdate
:: Log file set LOGFILE=%USERPROFILE%\Desktop\GPUpdate_Log_%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%_%TIME:~0,2%%TIME:~3,2%.txt set LOGFILE=%LOGFILE: =0%
echo. echo [DONE] Log saved to: %LOGFILE% pause exit /b 0 More flexible, supports remote computers. Save as Invoke-GPUpdate.ps1 .
:: Show current applied policies (without updating) gpresult /r





