Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to import employeeNumber from CSV into AD

Posted on 2013-06-07
7
Medium Priority
?
857 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 2000 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Loops Section Overview

885 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