enable-mailbox: leading or trailing whitespace
When I run enable-mailbox it errors out with this: The property value is invalid. The value can't contain leading or trailing whitespace.
Get-user gets me this:
WARNING: The object domainname/OUS/username has been corrupted, and it's in an inconsistent state.
The following validation errors happened:
WARNING: The property value is invalid. The value can't contain leading or trailing whitespace.
When I look in AD users and computers MMC I don't see any whitespaces.
How to fix this whitespace or invalid characters for one specific user and a group of users if necessary?
Thanks
December 16th, 2011 2:40pm
On Fri, 16 Dec 2011 19:25:32 +0000, Mr.Kris wrote:
>When I run enable-mailbox it errors out with this: The property value is invalid. The value can't contain leading or trailing whitespace.
>
>Get-user gets me this:
>
>WARNING: The object domainname/OUS/username has been corrupted, and it's in an inconsistent state. The following validation errors happened: WARNING: The property value is invalid. The value can't contain leading or trailing whitespace.
>
>
>
>When I look in AD users and computers MMC I don't see any whitespaces.
>
>How to fix this whitespace or invalid characters for one specific user and a group of users if necessary?
First you have to identify what property it is that has the
leading/trailing whitespace. Is it the sAMAccountname?
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
December 16th, 2011 3:09pm
That I don't know. Can you please help me on that?
December 16th, 2011 4:23pm
On Fri, 16 Dec 2011 21:08:51 +0000, Mr.Kris wrote:
>That I don't know. Can you please help me on that?
Try running get-user with the -verbose switch on one user and see it
it coughs up any more information.
These are the properties I'd look at first:
firstname
lastname
displayname
initials
name
samaccountname
userprincipalname
Knowing how the AD user object was created would help, too. I don't
think that any of the powershell cmdlets would allow an invalid value
to be inserted. The same goes for the ADUC. But any custom coded
creation of the AD user that didn't verify that the data was correct
could certainly accomplish that misdeed.
Things like CSVDE, LDIFDE, ADSIEDIT, ADSI, etc. are all ways that can
introduce errors.
Something like this might point out the problem:
$u=get-user <USERNAME>
$props = "firstname",
"lastname",
"displayname",
"initials",
"name",
"samaccountname",
"userprincipalname"
$props | foreach{
if ($u.$_.trim() -ne $u.$_)
{
write-host "Property $_ has leading or trailing spaces"
}
}
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
December 16th, 2011 5:14pm
I used ADSIEdit to find out that cn is the culprit. It has a space. Yes, thru' CSVDE I do mass imports and causes this issue. I should do more checking in excel before I run it.
I then used:
set-user <username> -name "FirstName LastName"
All fixed ;)
December 16th, 2011 5:55pm
On Fri, 16 Dec 2011 22:40:46 +0000, Mr.Kris wrote:
>I used ADSIEdit to find out that cn is the culprit. It has a space. Yes, thru' CSVDE I do mass imports and causes this issue. I should do more checking in excel before I run it.
You can use a CSV file as a data source. Import it into a powershell
script and do the data validation and user object creation in the same
script.
>
>
>
>I then used:
>
> set-user <username> -name "FirstName LastName"
>
>
>
>All fixed ;)
>
>
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
December 16th, 2011 10:33pm
Hi Mr.Kris,
Now I will try to close the thread, If you still have any question on this issue, please feel free to let me know.
Thanks,
Evan Liu
TechNet Subscriber Support
in forum
If you have any feedback on our support, please contact
tngfb@microsoft.com Evan Liu
TechNet Community Support
December 24th, 2011 9:40pm
Glad your problem has been resolved.
Just as Rich said, you can use CSV file as a data source.
Here are some commands you can used to create user with CSV files
$users = import-csv
"C:\Users.csv"
$container = [ADSI] "LDAP://cn=Users,dc=YourDomain,dc=local"
$users | foreach {
$UserName = $_.UserName
$newUser = $container.Create("User", "cn=" + $UserName)
$newUser.Put("sAMAccountName", $UserName)
$newUser.SetInfo()
$newUser.psbase.InvokeSet('AccountDisabled', $false)
$newUser.SetInfo()
$newUser.SetPassword("Password01!")
}
Thanks,
Evan Liu
TechNet Subscriber Support
in forum
If you have any feedback on our support, please contact
tngfb@microsoft.com Evan Liu
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
December 25th, 2011 12:08am
On Mon, 19 Dec 2011 04:55:30 +0000, Evan Liu wrote:
>Here are some commands you can used to create user with CSV files
The example suffers from the same problem -- it leaves
leading/trailing whitespace where none should exist!
This would take care of that situation:
$UserName = $_.UserName.Trim()
Vetting data before it's used is an important part of writing programs
or scripts.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
February 25th, 2012 6:00pm