Musings on the splendour of PowerShell One-Liner: Targeted Remote Group Policy Updates - PoSh Chap - Site Home - TechNet Blogs

PoSh Chap

Musings on the splendour of PowerShell

One-Liner: Targeted Remote Group Policy Updates

One-Liner: Targeted Remote Group Policy Updates

  • Comments 1
  • Likes

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*'} |

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
  • Thanks

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment