Import file to change group membership

Say, you get a list of groups and users which need to be in them, how do you quickly add the users to the groups?

For example, Andriy had to import group membership from files like:
Orgname Username
OP-420-HO-S-00 net1111
RB-430-AD-A-12 net2222
AC-200-RL-B-10 net1234

In which Orgname is indeed the name of the group.

In such cases, Import-CSV and Add-QADGroupMember are your friends. Just don’t forget to properly specif the column numbers and the delimiter used in the files you get:

Import-Csv C:\list.csv -Delimiter ' ' | 
 ForEach-Object {
  Add-QADGroupMember -Identity $_.Orgname -Member $_.Username 
 }

Leave a comment




Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

April 2010
M T W T F S S
 1234
567891011
12131415161718
19202122232425
2627282930