Sunday, 9 May 2021

How to add multiple user to multiple group using PowerShell

 How to add multiple users to multiple groups using PowerShell


File format

 







PowerShell Command

 

Import-Csv "C:\Users\Administrator\Desktop\bulkuserandgroup.csv" | Group-Object Group | % {

      $users = $_.Group | % { Get-ADUser $_.Accountname }

    Add-ADGroupMember -Identity $_.Name -Member $users

}


No comments:

Post a Comment