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.
Wynn Slots for Android and iOS - Wooricasinos
ReplyDeleteA free app for goyangfc.com slot machines from WRI Holdings Limited that wooricasinos.info lets you https://vannienailor4166blog.blogspot.com/ play the herzamanindir.com/ popular games, https://septcasino.com/review/merit-casino/ such as free video slots, table games and live casino