I am prepping a script for our accounts management team that'll create users accounts fairly quickly. I seem to always get an error stating:
New-ADUser : A value for the attribute was not in the acceptable range of values
I have looked online and through here a bit but some of the solutions that others posted didn't work for me. The code is below:
Write-Host "New Business Services Account" -ForegroundColor Green
$Name = Read-Host "Enter First and Last Name"
$DisplayName = $Name
$GivenName = Read-Host "Enter First Name"
$Surname = Read-Host "Enter Last Name"
$EmailAddress = Read-Host "Enter Email Address"
$SamAccountName = Read-Host "Enter SamAccountName"
#$UserPrincipalName = $GivenName.$Surname + "@{entrustenergy}.com"
$Office = Read-Host "Enter Office"
$City = "Houston"
$State = "TX"
$ZipCode = Read-Host "Enter Zip Code"
$Country = "United States"
$Company = "Entrust Energy, Inc."
$JobTitle = Read-Host "Enter Job Title"
$Department = Read-Host "Enter Department"
$Manager = Read-Host "Enter Managers Username"
$Path = "PathOUisHere"
$Password = Read-Host "Enter Password"
New-ADUser -Name "$Name" -GivenName "$GivenName" -Surname "$Surname" `
-DisplayName "$DisplayName" -EmailAddress "$EmailAddress" `
-SamAccountName "$SamAccountName" -StreetAddress "$Address" -City "$City" `
-State "$State" -PostalCode "$ZipCode" -Country "$Country" `
-Company "$Company" -Title "$JobTitle" -Department "$Department `
-Manager "$Manager" -Path "$Path" -Enabled $true `
-AccountPassword (ConvertTo-SecureString "$Password" -AsPlainText -Force) `
-ChangePasswordAtLogon $true -PassThru