New-ADUser Help

We have found in our org (OnPrem AD that syncs to Azure AD, One way) that we can’t set the country this way -c <country name>. We have to set all three attributes (c, co and countrycode) at the same time using this:

-replace @{c= $r.country;co= $r.countryname;countrycode= $r.countrycode}

If I try to use this in a New-Aduser command, it gives me the 'a parameter cannot be found that matches parameter name ‘replace’. I also tried using -set instead of replace but I get the same error.

In this situation is it possible to set the country in the New-Aduser command or will I need to wait until it’s created and set it using Set-Aduser?

There is the parameter -Country … but if that’s not enough you can use the parameter -OtherAttributes.

Example 2 shows how to use it:

… and BTW - When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

Hi, welcome back :wave:

You can supply a hashtable to the OtherAttributes parameter.

1 Like

Unfortunately in our setup we can’t just set -Country (-c) independently. We have to set the 3 in combo (-Country, -co and -country code). We spent a couple hours figuring this out about 2 months ago. So I am trying to figure out if I can use it in the new-aduser.

I can try the -OtherAttributes since co and countrycode are not exposed as parameters for this command.

You should have come here earlier … it took 20 minutes to get an answer. :wink:

:joy: I meant we spent that time figuring out that the 3 attributes had to be set in tandem in order to set the country.

But you are right, I should have come here earlier, it probably wouldn’t have taken as much time to figure it out