Active Directory query
Hey,
I have been tasked with compiling names, usernames and e-mails for new distance learning students for next month. I set them up, everything is all good but then HR wants a excel of the exact names that they can copy and paste so avoid any issues when the course starts.
I can export the names from ad (using the export list), which is a massive help. I have had a quick look for a solution and while it’s very doable, I don’t have time to figure it out. Microsoft has a good tutorial but it’s also very hard to read for a newbie (I don’t really understand the syntax yet!).
I will finish this manually before anyone might be able to help, but its out of principle now. I won’t be able to sleep at night not knowing how to simply extract 4 items of information from AD.
All the info needed is under the fields;
First name,
Last name,
e-mail,
User login name.
I hate knowing that I’m literally 30 odd keys away from a simple script to get this info from AD to a text file!
Kai.
I have been tasked with compiling names, usernames and e-mails for new distance learning students for next month. I set them up, everything is all good but then HR wants a excel of the exact names that they can copy and paste so avoid any issues when the course starts.
I can export the names from ad (using the export list), which is a massive help. I have had a quick look for a solution and while it’s very doable, I don’t have time to figure it out. Microsoft has a good tutorial but it’s also very hard to read for a newbie (I don’t really understand the syntax yet!).
I will finish this manually before anyone might be able to help, but its out of principle now. I won’t be able to sleep at night not knowing how to simply extract 4 items of information from AD.
All the info needed is under the fields;
First name,
Last name,
e-mail,
User login name.
I hate knowing that I’m literally 30 odd keys away from a simple script to get this info from AD to a text file!
Kai.
Comments
-
jibbajabba Member Posts: 4,317 ■■■■■■■■□□I don’t have time to figure it out.
If you can't sleep anyway - why don't you use the time to google
(not trying to be funny)My own knowledge base made public: http://open902.com -
brombulec Member Posts: 186 ■■■□□□□□□□Use Active Directory Extension for Powershell from Quest (it's free) and write one-liner in PowerShell.
Hint: use Get-QADUser cmdlet -
Kai123 Member Posts: 364 ■■■□□□□□□□jibbajabba wrote: »If you can't sleep anyway - why don't you use the time to google
(not trying to be funny)
I will still hit a wall with the syntax, and I will be at home where I cant test out the scripts. I would have to wait till Monday…a whole weekend ruined! :P
-
Asif Dasl Member Posts: 2,116 ■■■■■■■■□□I don't have a server in front of me right now, but Snow.Bros had a problem with CSVDE which is exactly what you want to use. Just for future reference you did it the opposite way around - you want to make the Excel sheet first then CSVDE. But luckily you can do it in reverse also..
-
Kai123 Member Posts: 364 ■■■□□□□□□□Dude ... it's 10 minutes of reading help ...
Why comment like that on circumstances you’re not aware of?I don't have a server in front of me right now, but Snow.Bros had a problem with CSVDE which is exactly what you want to use. Just for future reference you did it the opposite way around - you want to make the Excel sheet first then CSVDE. But luckily you can do it in reverse also..
Now that I have time to have a crack at this, It would have been so much easier adding users using CSVDE. My experience with AD so far is only creating users, managing a few groups and basic AD troubleshooting (unlocking accounts).
Last question for peace of mind. Any command to export data will not remove the data?
-
kj0 Member Posts: 767Exporting is copying data. not cutting and pasting.
...unless you tell it to remove the data.
Grab some MS books, or CBT nuggets has some great Server 2008 and 2012 videos by James I. Conrad. Show you how to use the CSVDE -
Kai123 Member Posts: 364 ■■■□□□□□□□Exporting is copying data. not cutting and pasting.
...unless you tell it to remove the data.
Grab some MS books, or CBT nuggets has some great Server 2008 and 2012 videos by James I. Conrad. Show you how to use the CSVDE
That’s all I need to know! I am very compulsive and even the shred of doubt is enough to make me ask silly questions.
The link Asif posted seems to have everything I need. Now I know I can afford to make mistakes I can start trying to export what I need.
-
kj0 Member Posts: 767^^ Edit - What he said!
This should help a little more, if you're the type of person who can learn more from watching than reading. https://www.youtube.com/watch?v=jJ4jwduk7wQ
It's funny, I seem to remember more about MCSE content now than I did when I was attempting the exams (and I haven't read anymore since) ...Damn my long term memory!! -
Asif Dasl Member Posts: 2,116 ■■■■■■■■□□That guy in the video needs to know how to use the CONCATENATE function in Excel, you'd be all year writing that stuff out that he does at 3m 30s... but other than that it's a good video
Column A (first name) - Column B (last name) - Column C (login name) - Column D (email)
Column A is Bob
Column B is Terwilliger
Column C is =A1&B1 which gives you the "BobTerwilliger"
Column D is =CONCATENATE(A1&"."&B1&"@mydomain.com") which gives you "Bob.Terwilliger@mydomain.com"
That's how you use concatenate in Excel.. -
ccnxjr Member Posts: 304 ■■■□□□□□□□Maybe it's time to set up a virtual mini-domain / home lab ?
That way you don't have to wait until Monday to test out your theories, also , you can play around with more riskier challenges. -
Qord Member Posts: 632 ■■■■□□□□□□Powershell all the way. How do you have them separated in AD from other user objects? Getting the info you want is super easy, getting *only* those users would be the tricky part.
get-aduser * -properties * | select givenname,surname,samaccountname,emailaddress
You can try this with just you by adding your username right after get-aduser. If you've got all the users you need in one OU/CN, you can add a searchbase to tell powershell where to look for the users you need.
EDIT: Syntax...forgot a *.