Solved

Use Powershell to find msExchVersion with null value and then replace it

Posted on 2014-07-22
10
2,296 Views
Last Modified: 2014-07-23
I have a number of accounts that have been created in Exchange 2010 from a script that end up as Legacy Mailboxes. I've seen several sources with scripts to fix this but they do not work. The issue is that the value of the AD Attribute msExchVersion is null. I need to find the mailboxes in a specific OU that have this null value and then set the msExchVersion to 44220983382016 for Exchange 2010. Using the AD tools I can find the null values with this:
Get-ADUser -LDAPFilter "(!(msExchVersion=*))" -resultSetSize $null -searchbase "OU=Test,OU=TestUsers,OU=VOIP,OU=User Accounts,DC=dp,aom,DC=priv" 

Open in new window

However, I cannot find a way to set the attribute to the correct value.

I'm happy to use the AD commands or the quest commands so long as it works. Your assistance is appreciated.
0
Comment
Question by:hcca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 14

Expert Comment

by:Justin Yeung
ID: 40212477
Get-ADUser -LDAPFilter "(!(msExchVersion=*))" -resultSetSize $null -searchbase "OU=Test,OU=TestUsers,OU=VOIP,OU=User Accounts,DC=dp,aom,DC=priv"  | % {set-aduser $_ -add @{msExchVersion="44220983382016"}}
0
 

Author Comment

by:hcca
ID: 40212530
That works very well. Is there any way to add something like this to the script? This uses Exchange commands instead of AD commands. I left out the part where I set the  variable $dn hoping that I could use what was returned from the first part of the script.

Get-User "$dn" -IgnoreDefaultScope | Update-Recipient
0
 
LVL 14

Expert Comment

by:Justin Yeung
ID: 40212555
yes of course, however what is your version of exchange?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 14

Accepted Solution

by:
Justin Yeung earned 500 total points
ID: 40212575
Import-Module ActiveDirectory
Add-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010

$Users = Get-ADUser -LDAPFilter "(!(msExchVersion=*))" -resultSetSize $null -searchbase "OU=Test,OU=TestUsers,OU=VOIP,OU=User Accounts,DC=dp,aom,DC=priv"  
foreach ($User in $Users)
{
Set-aduser $User.SamAccountName -add @{msExchVersion="44220983382016"}
Start-sleep -second 2
Get-Mailbox $User.DistinguishedName -IgnoreDefaultScope | Update-Recipient
} 

Open in new window

0
 

Author Comment

by:hcca
ID: 40212624
The second part of this worked perfectly but it failed to set the Exchange version.

I had run the earlier script which did set the version. I then reset the version to <not set> for one user. When I ran the latest version I expected that to be corrected as well as the second part. I got this error in the PS window.

WARNING: The object domain.priv/User Accounts/VOIP/TestUsers/TEST/End User has been corrupted, and it's in an
inconsistent state. The following validation errors happened:
WARNING: ExchangeGuid is mandatory on UserMailbox.
WARNING: ExchangeGuid is mandatory on UserMailbox.
Property RoleAssignmentPolicy can't be set on this object because it requires the object to have version 0.10 (14.0.100
.0) or later. The object's current version is 0.0 (6.5.6500.0).
    + CategoryInfo          : NotSpecified: (0:Int32) [Update-Recipient], InvalidObjectOperationException
    + FullyQualifiedErrorId : 650032ED,Microsoft.Exchange.Management.RecipientTasks.UpdateRecipient

The problem did not occur for the users that I did not remove the msExchVersion value. Those accounts are now ready to go.
0
 
LVL 14

Expert Comment

by:Justin Yeung
ID: 40212723
so the user was in Exchange 2003? didn't you already migrated the mailbox over to 2k10?

why don't you change the attribute back to what it was and let exchange to handle the update?
0
 

Author Comment

by:hcca
ID: 40212773
I think this may be working fine. I've had a couple of squirrely things happen. I will get another batch to test with tomorrow. Thanks for your fine help. I was close with a couple of my attempts but you, Justin Yeung, nailed it all down.
0
 

Author Closing Comment

by:hcca
ID: 40212788
These accounts are being created through an AD sync process using FIM2010 with a vbproject. For some reason, when it creates the account it does not populate it completely for a regular exchange mailbox. I've seen a couple of posts that suggest running this:
Get-Mailbox | where {$_.RecipientTypeDetails -eq "legacymailbox"} | Set-Mailbox -ApplyMandatoryProperties
But that does not fix this issue. However, adding the msExchVersion by hand and then running -IgnoreDefaultScope | Update-Recipient against the boxes converts them to regular mailboxes and it all works. I know the real fix is to get the FIM2010 script to run properly. That will be my next step, but I needed a quick fix for a bunch of accounts coming down the pipe.
0
 

Author Comment

by:hcca
ID: 40215067
Last comment. I found that by adjusting the wait time from 2 to 10 fixed my problem. It takes a bit longer to complete but it does complete. The script will never be used for more than 12-20 accounts at a time.

Thanks for all the help.
0
 

Author Comment

by:hcca
ID: 40215393
Justin Yeung thanks for your help. I have found that if the script finds zero users with a null value for msExchVersion it continues on to the next part of the script. Is it possible to have the script end if no users are found with the null value? I've tried inserting some if / else code but have not been successful.
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision Office 365 tenants, synchronize your on-premise Active Directory, and implement Single Sign-On.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question