How to populate other attributes when using powershell 2.0 new-aduser?

15,252

The parameter "-otherAttributes @{}" fails in my AD. I found other way change this value in AD.

Try with this:

PS> Set-ADuser -identity joseiba -Clear 'msRTCSIP-PrimaryUserAddress'
PS> Set-ADuser -identity joseiba -Add @{'msRTCSIP-PrimaryUserAddress'='[email protected]'}

BR

Share:
15,252
Admin
Author by

Admin

Updated on August 04, 2022

Comments

  • Admin
    Admin over 1 year

    When trying to create users from a file I get an error when -otherAttributes @{} is added to ps script. I am new to powershell and can not get it to work. Any guidance is appreciated. This is My code:

    Import-Module ActiveDirectory
    $OU = 'ou=Staging OU, dc=Domain, dc=net'
    $usrfile = "\\servername\testuser.csv"
    
    Import-Csv $usrfile | 
    ForEach-Object {
         New-ADUser -SamAccountName $_.samaccountname -UserPrincipalName $_.Userprincipalname -Name $_.Name -DisplayName $_.displayname -GivenName $_.givenname -Surname $_.sn -Initials $_.initials -Title $_.title -OtherName $_.middlename `
    -Description $_.description -Department $_.department -EmployeeID $_.employeeid -Path $OU -Country $_.c `
    -OtherAttributes @{departmentNumber=$user.departmentnumber;localeID=$user.localid;extensionAttribute1=$user.extensionAttribute1;employeeType=$user.employeetype} `
    -AccountPassword (ConvertTo-SecureString "Password" -AsPlainText -Force) -Enabled $true `
    -PasswordNeverExpires $false -ChangePasswordAtLogon $true -PassThru 
        } > Import.log
    
  • Admin
    Admin almost 12 years
    I added some info about my issue by add comment. I don't really know how to use this page. Your comments will be greatly appreciated.