Monday, July 25, 2016

Powershell - Mass Link a Group Policy Object to a list of OUs

Powershell - Mass Link a Group Policy Object to a list of OUs

Step 1: Get your GP Object and save it to a variable:

$SystemCenter = Get-GPO -Name "System Center"

Step 2: Get your List of OUs

For me, my OUs are stored under Domain Users. This is a terrible practice, but it was implemented long before me, and moving it was going to be far more trouble than what the effort would yield. 
$OUs = Get-ADOrganizationalUnit -filter * -SearchBase "OU=Domain Users,DC=bbox,DC=org" | ? {$_.Name -like "*Computer*"}

Step 3: Link 'em Up

foreach ($obj in $OUs){
    #new-GPLink -Target $obj  -Guid $SystemCenter.Id --Whatif
    new-GPLink -Target $obj  -Guid $SystemCenter.Id

I recommend doing that with the What-IF parameter first. (commented out) to make sure you don't mess anything up.
Toy around with the Filter and Where-Object pipes from step 2 until you have the list that you like. You can alternatively just create a single dimensional array with the Distinguished Name of the OU as the only element. 


  1. Wynn Slots for Android and iOS - Wooricasinos
    A free app for slot machines from WRI Holdings Limited that lets you play the popular games, such as free video slots, table games and live casino

  2. Based on these criteria, we feel one of the best video poker bonuses are below. This is a good distance of claiming that you can relaxation assured our payouts are as high as one of the best casinos and, in fact, with the Mega Jackpot, are even higher. And, Video 카지노 Poker Classic is a very honest sport phrases of|when it comes to|by means of} how arms are dealt nicely as|in addition to} the payouts for each of our paytables.