Powershell new-aduser attribute was not in the acceptable range

13,307

it was country that was the problem, it took a bit but I was able to comment out most of the block until I found that $_.Country did not work

Share:
13,307
Steve Hobbs
Author by

Steve Hobbs

Updated on June 04, 2022

Comments

  • Steve Hobbs
    Steve Hobbs almost 2 years

    I'm having an issue with the following Powershell script. It is

    a value for the attribute was not in the acceptable range of values Line 1 char 59

    Import-Csv .\tableofusers.csv | foreach-object {New-ADUser -Path "ou=ou,dc=dc" -SamAccountName $_.SamAccountName -Name $_.name -DisplayName $_.name -GivenName $_.gn -SurName $_.sn -StreetAddress $_.SA -city $_.city -state $_.state -PostalCode $_.PostalCode -Country $_.Country -officephone $_.officephone -emailaddress $_.emailaddress -AccountPassword (ConvertTo-SecureString "Password1" -AsPlainText -force) -enabled $true -PasswordNeverExpires $false -Passthru}

    I have been over it many times I cannot see the issue in or arround on character 59 any help would be welcome