Link to home
Start Free TrialLog in
Avatar of scfcu
scfcu

asked on

Set-QADuser import from csv; Manager Attribute doesn't populate!!

I am new to scrripting however I currently have a CSV file that I am trying to use to import user attributes.  All the attributes are importing except for the manager attribute.  I have enterend the Distigushed Name for Manager in the proper location however it is not importing



The command I run from quest managment shell is
Import-Csv c:\users5.csv | Set-QADUser -Identity {$_.samAccountName} -import

the csv is popluated like so.
samAccountname,sn,givenname,name,displayname,title,department,manager,telephonenumber,physicalDeliveryOfficeName
samname,name,sam,sam n,sam name,Admin,MIS,"CN=managername,OU=Users,OU=ouname,DC=domain,DC=com",214-555-1212,test

Avatar of Aard Vark
Aard Vark
Flag of Australia image

Try this.
Import-Csv c:\users5.csv | ForEach-Object {Set-QADUser -Identity $_.samAccountName}

Open in new window

Avatar of scfcu
scfcu

ASKER

This did not work!  Thanks though.
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of scfcu

ASKER

I also found this on powergui forum
Import-Csv C:\users4.csv | Select-Object -Property SamAccountName,@{'Name'='Manager';'Expression'={(Get-QADUser -Identity $_.Manager).dn}} | Set-QADUser -Identity {$_.SamAccountName}

I like yours better though.   I can just add in the other attirbutes to your code.

Thanks Chris!


Randy

No worries.

Very odd that the version you have there works, the strings it returns are identical, and if they weren't right it would fail to find the manager.

Did they manage to give a reason why along with the work around at all?

Chris
Avatar of scfcu

ASKER

No they didn't,  the only difference I guess between yours and the one on powergui.com is that the one on powergui will find the dn for the name you put in the csv and it will add it.  Pretty cool!  I am not sure why you have to specify the attribute for it to work though.  Here is the link.

http://powergui.org/thread.jspa?threadID=7618&tstart=270
The odd thing is, your manager field is already a DN in the input here:

manager
"CN=managername,OU=Users,OU=ouname,DC=domain,DC=com"

I was testing on that basis, it should have worked (but doesn't appear to).

If you were using:

manager
managerusername

Then the solution would have made a lot of sense because it does the conversion to DN quite neatly.

Ah well, I'll test some more and see if there's something daft that's breaking it :)

Chris