Adding multiple users in the same OU is easy task, only you need to select users and add them to multiple groups. The Biggest challenges is when adding users from multiple OU’s in multiple groups.
In this blog, We will learn to add multiple users from different ou’s into multiple AD groups.
We have created a CSV file in which Active Directory users(sAMAccountName) and group names are written and this CSV file will be called in powershell script.
Run the Below powershell script on any domain controller, member server or a client machine with delegated rights or domain admin account. # Start transcript # Import active directory module for running AD cmdlets Import-module ActiveDirectory #Store the data from UserList.csv in the $List variable $List = Import-CSV .\UserList.csv #Loop through user in the CSV ForEach ($User in $List) { #Add the user to the TestGroup1 group in AD Add-ADGroupMember $User.Group -Members $User.User -ErrorAction Stop -Verbose }
How would i go about adding a delimiter to the script to seperate multiple groups to a single user?
For example:
User,Group
eng1,FinanceRO and Finance RW
eng2,FinanceRO and Helpdesk and infra_ops
etc…
Thanks!