Solved

How to import employeeNumber from CSV into AD

Posted on 2013-06-07
7
724 Views
Last Modified: 2013-06-07
:(
I think i lost the script that allows me to import/add the employeNumber from a CSV into AD Users
The csv has the following headers
SamAccountName,Surname,GivenName,Name,Department,Title,TelephoneNumber,Employee
Number

Open in new window

Just in case the following:
$AD = Get-ADUser -SearchBase "OU=COMPANY,DC=,DOMAIN=COM" -filter * -Properties sAMAccountName,sn,givenName,title,employeeNumber | Where { $_.DistinguishedName -notmatch "OU=VIP" -and $_.DistinguishedName -notmatch "OU=DA"} | Select-Object  sAMAccountName,sn,givenName,title,employeeNumber

Open in new window

0
Comment
Question by:namerg
  • 4
  • 3
7 Comments
 

Author Comment

by:namerg
ID: 39230370
I think, I got it.
Clear-Host
$Ceridian = Import-Csv "c:\scripts\ceridian\CeridianUsersClockNumberPopulate.csv"
Foreach ($Ceridian_User in $Ceridian){
#SamAccountName,Surname,GivenName,Name,Department,Title,TelephoneNumber,EmployeeNumber
	write-host "From Ceridian"
	write-host $Ceridian_User."SamAccountName" $Ceridian_User."Surname" $Ceridian_User."GivenName" $Ceridian_User."EmployeeNumber"
	Get-ADUser $Ceridian_User.sAMAccountName  | Set-ADUser -employeeNumber $Ceridian_User."EmployeeNumber" -ErrorAction SilentlyContinue -ErrorVariable Err1
	write-host "EmployeeNumber SET Sleeping 5 seconds"
	write-host ""
	start-sleep 5
}

Open in new window

0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39230624
Following code also will do...
Import-Csv "c:\scripts\ceridian\CeridianUsersClockNumberPopulate.csv" | %{
Set-ADUser $_.sAMAccountName -employeeNumber $_.EmployeeNumber -ErrorAction SilentlyContinue -ErrorVariable Err1
}

Open in new window

0
 

Author Comment

by:namerg
ID: 39230663
Hi Subsun, need advice, for this script that i am writing, i did a bullet proof but some other issues came up should i post it as a project ?

Thanks for your help,
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 40

Expert Comment

by:Subsun
ID: 39230674
yes please..if it is related to this question then you can post it here itself..
0
 

Author Comment

by:namerg
ID: 39230681
I mean the whole script/project, it is related to multiple questions that you and footech have contributed. Can i submit it as a project ?
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39230687
Yes you can.. Please explain it in detail.. :)
0
 

Author Comment

by:namerg
ID: 39230690
jajaj, yes I will
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now