Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

How to add user to multiple groups from .csv

$
0
0

Hi All,

I have tried researching previous posts, but didn't find anything in relation to adding users to multiple groups from .CSV file import.  I have been able to get the below script to work on adding multiple users to a group, but now would like to modify it to add a user to multiple groups.  Any assistance would be greatly appreciated. 

File comma delimited import file; (*.CSV)

NameDomainMemberOf
<UserName><DomainName><SecurityGroup1>
<UserName><DomainName><SecurityGroup2>

 

Import-ModuleActiveDirectory

 

$members

 

 

=Import-CSV'H:\posh\Scripts\Adding Users to Multiple Groups.csv'

$members

 

 

|ForEach-Object {Add-QADGroupMember-Identity'SecurityGroup1,SecurityGroup2'-Service'DomainName'-Credential <Cred> -Member$_.samAccountname}

This script is only 3 lines.


Viewing all articles
Browse latest Browse all 10624

Trending Articles