Need help with PowerShell to import Hire Date into profile


hello,

i have script below not work below , updating 1 field in profile in ad. importing csv file, below:

samaccountname, hiredate

bjones,2/14/1999

mloo, 5/12/2001

in csv, correct format? hiredate custom attribute.

the below powershell script error below:

set-aduser : parameter cannot found matches parameter name
'hiredate'.
@ line:4 char:14
+   set-aduser -hiredate $($user.hiredate)
+              ~~~~~~~~~
    + categoryinfo          : invalidargument: (:) [set-aduser], parameterbind
   ingexception
    + fullyqualifiederrorid : namedparameternotfound,microsoft.activedirectory
   .management.commands.setaduser

here script:

           

import-module activedirectory            
$users = import-csv -path d:\scripts\hiredatetest.csv          

foreach ($user in $users) 
{             
 get-aduser -filter "samaccountname -eq '$($user.samaccountname)'" -properties * -searchbase "cn=users,dc=domain,dc=com" |            
  set-aduser -hiredate $($user.hiredate)          
}

any advice on how working great help.


paul

hi paul,

to update extension attribute of users, please use parameter "-replace":

get-aduser -filter "samaccountname -eq '$($user.samaccountname)'" -properties * -searchbase "cn=users,dc=domain,dc=com" |set-aduser -replace @{hiredate=$($user.hiredate)}  

using cmdlet "set-aduser", please refer these articles:

http://technet.microsoft.com/en-us/library/ee617215.aspx

http://richardspowershellblog.wordpress.com/2012/03/22/updating-ad-users-in-bulk/

if there else regarding issue, please feel free post back.

best regards,

anna wang

technet community support



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Azure MFA with Azure AD and RDS

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com