Sunday, November 11, 2012

Exchange 2010: New-TestCasConnectivityUser.ps1 fails to create test user

If you haven’t created CAS connectivity test user, SCOM will fail on few tests (example: Test-OutlookConnectivity cmdlet run by SCOM action account). SCOM will complain that it can’t monitor Exchange.

Fast forward, you figured out already that you have to run New-TestCASConnectivityUser.ps1 to create test account per each database, so SCOM can do it job. Now TestCASConnectivityUser.ps1 fails with following message.

CreateTestUser : Mailbox could not be created. Verify that OU ( Users ) exists and that password meets complexity requirements. At C:\Program Files\Microsoft\Exchange Server\V14\Scripts\new-TestCasConnectivityUser.ps1:255 char:27 +   $result = CreateTestUser <<<<  $exchangeServer $mailboxServer $securePassword $OrganizationalUnit $UMDialPlan $UMExtension $Prompt + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,CreateTestUser

I found there is nothing wrong you and I are doing. It’s a built-in script we are trying to run. Users container exists every damn Active Directory. I even typed the password with correct complexity requirements one key at a time.

I found the script has a bug. you can fix it yourself. Here it is.

Open the script C:\Program Files\Microsoft\Exchange Server\V14\Scripts\new-TestCasConnectivityUser.ps1 in PowerShell ISE (or Notepad). Search for New-Mailbox (line 49 for me), see the exact line below. Remove the option -OrganizationalUnit:$OrganizationalUnit.

new-Mailbox -Name:$UserName -Alias:$UserName -UserPrincipalName:$UserPrincipalName -SamAccountName:$SamAccountName -Password:$SecurePassword -Database:$mailboxDatabaseName  -OrganizationalUnit:$OrganizationalUnit -ErrorVariable err -ErrorAction SilentlyContinue

That’s it. Now this script should run with no errors. If we don’t specify the OrganizationUnit, account will create in Computers container by default. Enjoy!! Smile

No comments:

Post a Comment

Followers

hit counter