Differences
This shows you the differences between two versions of the page.
| — | windows:scripting:ps_gpupdate [2019/10/31 09:06] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Domain wite update GPO using Powershell ====== | ||
| + | gpupdate / | ||
| + | gpupdate /force | ||
| + | <code bash> | ||
| + | #Get all computers | ||
| + | $cn = Get-ADComputer -filt * | ||
| + | |||
| + | #Get admin credentials | ||
| + | $cred = Get-Credential iammred\administrator | ||
| + | |||
| + | #Create sessions | ||
| + | $session = New-PSSession -cn $cn.name -cred $cred | ||
| + | #This will result in an error for each offline client | ||
| + | |||
| + | #Run command | ||
| + | icm -Session $session -ScriptBlock {gpupdate /force} | ||
| + | |||
| + | #Check if executed OK | ||
| + | icm -Session $session -ScriptBlock {Get-EventLog -LogName system -InstanceId1502 -Newest 1} | ||
| + | |||
| + | #remove session | ||
| + | remove-pssession $Session | ||
| + | </ | ||