Adding a user via PShell in AD UC

I would be very greatfull to anyone who can provide me with a Powershell to do the following.
Add a user to a domains specified OU in AD Users and Computers with the following fields filled in...

First Name:            John  
• Last Name:            Doe
• Job Title:            Manager
• Office Location:      College
• Telephone:            01245-592300
• Street:            Deer Street
• City:            Rhuddlan
• State/Province      Denbighshire
• Zip code:            LL17 5UH
• Fax:                  0345- 91736
• Department      Pengwern College
• Manager : Mr Manager

Anyone that can provide me with this today I will be so greatful for that.

Thanks everyone for the help though
Jason LaskeyICT Systems and Network EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sekar ChinnakannuStaff EngineerCommented:
You can add the user using New-ADUser command, refer this MS article for each and every attributes you can get clear details  http://technet.microsoft.com/en-us/library/ee617253.aspx if you are looking for a multiple user at same time the n you need to import the CSV file to perform same action http://pc-addicts.com/powershell-create-multiple-users-ver-2/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PsymoniousCommented:
I did this very quickly by using "PowerShell ISE" and "Import-Module Active Directory"

What you'd like to achieve looks probably like this
-------------------------------------
New-ADUser -Name "Doe John" -GivenName "John" -Surname "Doe" -Title "Manager" -Office "College" -OfficePhone "01245-592300" -StreetAddress "Deer Street" -City "Rhuddlan" -State "Denbigshire" -PostalCode "L17 SUH" -Fax "0345-91736" -Department "Pengwern College" -Manager "samAccountName of his managers active directory account" -Path "distinguishedName to the OU you'd like to create the account in"

For next time, i would recommend you to use your browser, then you would have found this article or some other examples.

New-ADUser
http://technet.microsoft.com/en-us/library/hh852238.aspx
0
bernardbrinkCommented:
Something like:
New-ADUser "John Doe" -Path "CN=Users,DC=Domain,DC=local" -Givenname "John" -Surname "Doe" -Title "Manager" -Office "College" -streetAddress "Deer Street" -City "Rhuddlan" -State "Denbighshire" -postalCode "LL17 5UH" -department "Pengwern College" -manager "<FullDN Manager>" -OtherAttributes @{telephoneNumber="01245-592300";facsimileTelephoneNumber="0345-91736"}

More information about this ps command: http://technet.microsoft.com/en-us/library/ee617253.aspx

Also, this doesn't cover login name etc.. That would be UPN or UserPrincipalName
0
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

Jason LaskeyICT Systems and Network EngineerAuthor Commented:
Sorry I was in a rush as had to dash out thanks for all the comments I will try the CSV option as initially what I would like to do is create the colums in a CVS, send it to the users and they fill it in..then just run a PS script against the *.csv file.
Any better ideas?
0
Jason LaskeyICT Systems and Network EngineerAuthor Commented:
0
PsymoniousCommented:
I'm working on a web based form that can be used by the human resources team.
The information of the form gets saved in csv format and will be automatically processed.
After the account is created the admin get an email that a new user was created and probably needs some final adjustments.
I will try to automate it as much as possible. Also with adding a mailbox and other properties.

But as you see, its basically the same. Importing a CSV file with PowerShell.
0
Jason LaskeyICT Systems and Network EngineerAuthor Commented:
@Sekar Chinnakannu:

Hi Mate OK so I changed the *.ps script to the following:

Import-Csv "NewUsers.csv" | ForEach-Object {
 $userPrinc = $_."Logon Username" + "@domain"
 New-QADUser -Name $_.Name `
 -ParentContainer $_."Container" `
 -SamAccountName $_."Logon Username" `
 -UserPassword "Password01" `
 -FirstName $_."First Name" `
 -LastName $_."Last Name"
 -Description $_."Job Title"
 -PhysicalDeliveryOfficeName $_."Office"
 -TelephoneNumber $_."Telephone Number" ` `
 -StreetAddress $_."Street Address" 
 -l $_."City" `
 -St $_."State/Province" 
 -PostalCode $_."Postal Code"
 -FacsimileTelephoneNumber $_."Fax"
 -Department $_."Department"
 -Title $_."Job Title"
 -Company $_."Company"
 -Manager $_."Manager"
 -CountryCode $_."Country"
 -UserPrincipalName $userPrinc `
 -DisplayName $_."Name" ;`
 Add-QADGroupMember -identity $_."Distribution Group" -Member $_."Logon Username" ;`
 Set-QADUser -identity $_."Logon Username" `
 -UserMustChangePassword $true `
}

Open in new window


But I get an error when running the ps script something about -Description $_."Job Title" char 3.
Any ideas as this is so frustrating.

Thanks for you assistance though
0
Jason LaskeyICT Systems and Network EngineerAuthor Commented:
OK 'Im officially at my whits end and need serious help with this I have done the following and setup the following but keep getting this error
"Missing expression after unary operator '-'.
At line:14 char:2"
Attached is the *.ps file and the Excel Spreasheet
Add-NewUsers.ps1.txt = PS script to run

New-Users.csv= csv to run ps script against

New-Users.xlsx= xlsx sent to users and they must fill in the details

Please help this is urgent been busy with this for a week and have no idea what the error means or where I am going wrong
Add-NewUsers.ps1.txt
New-Users.csv
New-Users.xlsx
0
Jason LaskeyICT Systems and Network EngineerAuthor Commented:
@Sekar Chinnakannu:

I managed to get it to work but now I have a problem what if there is already a nlastname user and now I want it to say "OK if the user nlastname exists make the username nlastname1. Is this possible?
0
Jason LaskeyICT Systems and Network EngineerAuthor Commented:
Eventually after playing around with this and doing some research and once again testing etc I eventually came right with this.
These are some of the resources I had to using and test in order to get to my result
http://www.morgantechspace.com/2014/04/Create-Bulk-AD-Users-from-CSV-using-Powershell-Script.html
NewEmail.-ActiveSyncDisabled.txt
0
Jason LaskeyICT Systems and Network EngineerAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 500 points for Sekar Chinnakannu's comment #a40302782
Assisted answer: 0 points for Jason Laskey's comment #a40349368

for the following reason:

Eventually after playing around with this and doing some research and once again testing etc I eventually came right with this.
These are some of the resources I had to using and test in order to get to my result
http://www.morgantechspace.com/2014/04/Create-Bulk-AD-Users-from-CSV-using-Powershell-Script.html,
along with  < Sekar Chinnakannu> reccomendation
0
Jason LaskeyICT Systems and Network EngineerAuthor Commented:
This is a brilliant How to Site with Video thanks again after eventually playing around with some ideas from this site and then tweaking my own *.ps1 script and my Excel Template, I have managed to accomplish the task at hand. Sorry for the long response as took a while before I was 100% certain
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.