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.
Whoops! There was an error and we couldn't process your subscription. Please reload the page and try again.