Hello,
I'm getting weired random results from PowerShell. Here is the code:
$UserName = "Test.Test10" $MatchingUsers = Get-Recipient -ANR "$UserName" | Where-Object {($_.RecipientType -eq "UserMailbox")} $MatchingUsers.Count
When I execute the above code in Exchange Management Console, it sometimes works and sometimes not. i.e., The user named "Test.Test10" exists in Active Directory, but not contain mailbox. So it should result "0" for $MatchingUsers.Count.
I tried to log-in all several Mailbox servers directly and the cleared all sessions and even rebooted couple of lab servers. Still the result is same!
I'm not sure whether this a bug in Exchange side or in PowerShell or my code is incorrect! Any suggestions/help would be greatly appreciated. Thanks!
It works sometimes:
It won't sometimes: