Solved

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

Posted on 2014-07-22
10
2,325 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

705 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