Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to import employeeNumber from CSV into AD

Posted on 2013-06-07
7
Medium Priority
?
837 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

 
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

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
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…

721 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