Add Multiple Users To a Group Policy Using PowerShell

In this blog post, I will show you how I add multiple users from a CSV file to an Active Directory Group Policy using PowerShell.

Why would you do it

The reason, you might need to do something like this when you are testing Group Policy and you want to test it in specific users before applying to all users.

Code

The code takes a CSV file with the SAMACCOUNTNAME value of the users and adds them to a Group Policy.

import-csv C:\CSV\users.csv | foreach{set-GPPermission -Name GPO_NAME -TargetName $_.samaccountname -PermissionLevel GpoApply -TargetType User }

CSV File Format

The CSV file should look like:

samaccountname
user01
user02

Processing…
Success! You're on the list.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.