Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1720
  • Last Modified:

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

0
scfcu
Asked:
scfcu
  • 3
  • 3
1 Solution
 
LearnctxEngineerCommented:
Try this.
Import-Csv c:\users5.csv | ForEach-Object {Set-QADUser -Identity $_.samAccountName}

Open in new window

0
 
scfcuAuthor Commented:
This did not work!  Thanks though.
0
 
Chris DentPowerShell DeveloperCommented:

I can confirm that it doesn't seem to set manager. You can work around the problem but I can't tell you why it's failing to set.

To work around it you can do this after the original import:

Import-CSV "C:\Users5.csv" | %{ Set-QADUser -Identity $_.samAccountname -Manager $_.Manager }

Chris
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
scfcuAuthor Commented:
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
0
 
Chris DentPowerShell DeveloperCommented:

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
0
 
scfcuAuthor Commented:
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
0
 
Chris DentPowerShell DeveloperCommented:
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now