One-Liner: Targeted Remote Group Policy Updates
Windows 2012 added one additional cmdlet to the PowerShell GroupPolicy module - Invoke-GPUpdate
When used in conjunction with the ActiveDirectory PowerShell cmdlets we can easily target remote group policy updates. Here's a one-liner to run a Group Policy update on all Windows Server 2012 systems in a domain:
Get-ADComputer -Filter {OperatingSystem -like 'Windows Server 2012*'} |
ForEach-Object {Invoke-GPUpdate -Force -Computer $_.DnsHostName}
The -Filter parameter of the Get-ADComputer cmdlet is used to produce an array of 2012 computer objects. These are then passed, one-by-one, down the pipeline into the Invoke-GPUpdate cmdlet, where a 'force' update is scheduled on the 2012 host.
The targeting possibilities are (almost) endless. Here's one for servers from a file:
${c:servers.txt} | Invoke-GPUpdate
Comments
- Anonymous
May 20, 2014
Thanks - Anonymous
November 07, 2014
much appreciated