Home > front end >  New-ADUser -POBox returns "A value for the attribute was not in the acceptable range of values&
New-ADUser -POBox returns "A value for the attribute was not in the acceptable range of values&

Time:12-17

We have a script that creates users but sometimes failes with

New-ADUser -name "test" -pobox "Streetname Streetname2 99, EU-1010 Country"
A value for the attribute was not in the acceptable range of values

So I did a eleminitaion of parameters where I commented out one after another, the failing link was POBox. Many other posts sugests that -Country is a common fault but this is not the case here (we are using country codes and everything works fine).

I can't seem to find when it works and not, is there any limits to POBox-name? Anything that can cause the failure? Microsoft Docs just says "String value"

CodePudding user response:

The value of the postBoxOffice attribute (to which the -POBox parameter maps), is restricted to a maximum of 40 characters.

The sample string in your question, "Streetname Streetname2 99, EU-1010 Country", is 42 characters long :)

You can inspect the maximum length of any string-syntax attribute by inspecting the rangeUpper attribute on the corresponding schema entry for the target attribute:

PS ~> $poBoxSchema = Get-ADObject -Filter 'lDAPDisplayName -eq "postOfficeBox"' -SearchBase (Get-ADRootDSE).SchemaNamingContext -Properties rangeUpper
PS ~> $poBoxSchema.rangeUpper
40
  • Related