ebrown35
 New Member Posts:30

 |
| 02 Dec 2009 12:04 PM |
|
Ok I have a .csv that contains samaccountname and a group DN for a list of users:
User Group user1 ' CN=group1,OU=subcompany,OU=Exchange,DC=Fabrikam,DC=com' user2 ' CN=group1,OU=subcompany,OU=Exchange,DC=Fabrikam,DC=com'
How can I write a script that will add the user in the first header to group in the second header. I know that the get-qadgroupmember - add is going to be looking for a user DN. |
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
ebrown35
 New Member Posts:30

 |
| 03 Dec 2009 08:08 AM |
|
Thanks Shay! Is there a way for it tow work if the group cloumn has more thatn one group in it? |
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
| 03 Dec 2009 12:43 PM |
|
yes, if there is a character that delimits the groups then you can split on that delimiter, for instance the following is delimited by ";": Group ' CN=group1,OU=subcompany,OU=Exchange,DC=Fabrikam,DC=com'; ' CN=group2,OU=subcompany,OU=Exchange,DC=Fabrikam,DC=com' import-csv users.csv | foreach { $user = $_.user $_.group.split(";") | foreach { Add-QADGroupMember -Identity $_ -Member $.user } }
|
|
Shay Levy Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter: @ShayLevy |
|
|
ebrown35
 New Member Posts:30

 |
| 04 Dec 2009 07:03 AM |
|
Thanks again, I really am starting to get a handle on this. |
|
|
|
|
Mr Coffee
 New Member Posts:5

 |
| 09 Feb 2010 11:27 AM |
|
I have a CSV that has group in one colum and users in the second colum where each user is seperated by a ; Group1, user1; user2; user3 Group2, user2; user3; user4 What would the syntax look like for that import? Than you very much.
|
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
| 09 Feb 2010 11:50 AM |
|
Assuming the column names are GroupName,Members and you're using Quest AD cmdlets: import-csv groups.csv | foreach { Add-QADGroupMember -Identity $_.GroupName -Member $_.Members.Split(";") |
|
Shay Levy Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter: @ShayLevy |
|
|
Mr Coffee
 New Member Posts:5

 |
| 15 Feb 2010 07:31 AM |
|
How would I go about doing error checking on this script? I find that if it cannot resolve one name it appears to fail to import every one. This is a cross org migration and a number of objects did not come over thing were renamed everyone got new SMTP's. If there was a way to dump out to txt the errors but to keep importing it would be a great time saver. The process of continuing to attempt to import for a selected group as opposed to importing no one to that list hinders me more than anything. |
|
|
|
|