date join and emp id bulk add

Dear Team

The following objects have been added to the active directory 2008 R2.  there are about thousand of users in my existing environment. My question is possible way of adding join date automatically rather than adding manually?

Is it possible for me to create a CSV file and input the date join and emplyee id to add the employee id or what is the easiest way to add. 

  1. Employee ID
  2. Date join(Employee)

Please help me.

Thank you

Mahesh Leema

Dear Team

The following objects have been added to the active directory 2008 R2.  there are about thousand of users in my existing environment. My question is possible way of adding join date automatically rather than adding manually?

Is it possible for me to create a CSV file and input the date join and emplyee id to add the employee id or what is the easiest way to add. 

1.       Employee ID

2.       Date join(Employee)


Please help me.

Thank you

Mahesh Leema

June 11th, 2013 8:24pm

I do not see a attribute of JoinDate, so I am not sure where this field would go. You can do it with a csv file, but there would need to be three fields, sAMAccountName, EmployeeID, and JoinDate. That way you know what user to put the proper information to, then can do something like

Import-Csv C:\Users.csv | ForEach-Object { Set-ADUser -Identity $_.sAMAccountName -EmployeeID $_.EmployeeID -JoinDate $_.JoinDate }

You can read the help file for the cmdlet Set-ADUser by running Get-Help Set-ADUser -Detailed

The code listed is just for an understanding and will most likely fail so do not run it.

Free Windows Admin Tool Kit Click here and download it now
June 11th, 2013 8:34pm

I concur with clayman2, I do not see a JoinDate attribute anywhere. I doubt Set-ADUser will have a parameter for it, so you'll most likely need to use the LDAP attribute name to set it.
June 11th, 2013 8:36pm

Also, seeing that JoinDate may not be a normal attribute, Set-ADUser may not be able to set it, or just doesn't have a parameter to set it, so you may need to use the -Replace parameter which takes in a hash table

Import-Module ActiveDirectory

Import-Csv C:\Users.csv | ForEach-Object {
  Set-ADUser -Identity $_.sAMAccountName -Replace @{EmployeeID="$($_.EmployeeID)";JoinDate="$($_.JoinDate)"}}

Again, this has not been tested, so I am not sure if it will work, you can add the -WhatIf switch to the Set-ADUser cmdlet, to see what will happen without actually changing anyt
Free Windows Admin Tool Kit Click here and download it now
June 11th, 2013 8:54pm

Which is a customize attribute newly created based on the company requirement.

CSV file

Name,SamAccountNAme,UPN,DisplayN,Manager,Description,Department,EmployeeID,Path,Enabled,Password
First1 Last10,First1.Last10,First1.Last10@contoso.com,Display Name4,Administrator,Consultant,IT,444,"OU=Users,OU=Technical,OU=TechOne Corporate,DC=test,DC=local",$True,P@ssw0rd

Power Shell Script

import-csv C:\new\Users.csv | % {New-ADUser -Name $_.Name -SamAccountName $_.SamAccountName -UserPrincipalName $_.UPN -DisplayName $_.DisplayN -manager $_.Manager -Description $_.Description -Department $_.Department -EmployeeID $_.EmployeeID -Path $_.Path -Enabled $True -AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -force)}

above command works fine but when i add joindate attribute end up with some erros. please help

June 12th, 2013 7:48am

New-ADUser will not set JoinDate, because as you said it is a custom attribute, so the cmdlet has no idea about it. You can try using Set-ADUser with the -Replace parameter as I show above. If that doesn't work, then you will need to use other methods to set it.
Free Windows Admin Tool Kit Click here and download it now
June 12th, 2013 4:02pm

Hi

As clayman2 suggests, Set-aduser with -replace should works.

if your schema data type for joindate is generic date time, pls use [datetime] in front of $_.Joindate.

-Replace @{EmployeeID="$($_.EmployeeID)";JoinDate=[datetime]"$($_.JoinDate)"}}

rgds,

azmt

June 15th, 2013 7:24am

I will let you know the results ASAP
Free Windows Admin Tool Kit Click here and download it now
June 19th, 2013 9:03pm

Hi i have tested the above. its end up with some errors. Please find the attached file.

http://social.technet.microsoft.com/Forums/getfile/303902

Thank you

Partner

July 2nd, 2013 11:13am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics