christian
christian

Reputation: 69

AD custom attribute New-ADUser powershell

My problem is that i don't know how to address my custom Attributes in AD Powershell

I normally user something like this

New-ADUser -Name "Test" -surname "User" -description "User Description"

However when i try to set a value to my custom attribute such as

New-ADUser -Name "Test" -surname "User" -description "User Description" -reportingManagerID "012345"

I receive this error:

New-ADUser : A parameter cannot be found that matches parameter name 'reportingManagerID'.
At line:1 char:247
+ ... " -StreetAddress "address" -Surname "User" -reportingManagerID "1234"
+                                                ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.NewADUser

Any help would be much appreciated.

Upvotes: 1

Views: 5638

Answers (1)

gvee
gvee

Reputation: 17171

You need to use the -OtherAttributes parameter.

Quoting directly from the documentation here: https://learn.microsoft.com/en-us/powershell/module/activedirectory/new-aduser?view=winserver2012-ps

To set the value of a custom attribute called favColors that takes a set of Unicode strings, use the following syntax:

-OtherAttributes @{'favColors'="pink","purple"}

To set values for favColors and dateOfBirth simultaneously, use the following syntax:

-OtherAttributes @{'favColors'="pink","purple"; 'dateOfBirth'=" 01/01/1960"}

Upvotes: 2

Related Questions