Yesterday, many of our automation scripts started sending us error of not able to complete. On troubleshooting it was found that these all were failing on fetching remote mailboxes.
Get-RemoteMailbox -ResultSize unlimited
These were crashing with below Dr watson dump error & it was clear that it was occurring on particular mailbox object.
Only hint here shown was that Country code was wrongly used as UK which is not ISO code.
I tried other commands like get-user as well and those were also failing with above error but neither one was telling me the object that was causing it.
https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 (ISO Country Codes)
Country code of United Kingdom is GB so that should have been used instead of UK.
So next step was to find the mailbox on which someone had used the incorrect country code, it would not had been easy task if I was not familiar with CSVDE.
In a hope of finding the problematic user I had extracted all the enabled users with C & CO field.
csvde.exe -f c:\adextract.csv -r "(&(objectClass=user)(objectCategory=person)(!useraccountcontrol:1.2.840.1135188.8.131.523:=2))" -l "givenName, sn, mail, l,C,CO"
I filtered the extract on attribute C column but still I was not able to find any issues as all country codes used were perfect according to ISO standards.
I was scratching my head now :)
On further thinking/ troubleshooting and by just targeting the command on United Kingdom organizational unit, I was able to narrow down to the questionable object.
There is one more attribute that accepts the country codes and our telecom team is using that for fixing the locations of some of the office 365 users, you guessed it right
msExchUsageLocation was the attribute that I had not considered and that was the one that was set to incorrect value.
I had changed that to GB for the problematic user object and that resolved the issue.
If you face the similar error than do not forget to search for the msExchUsageLocation field as that might be wrongly set and causing these crashes.
If you ever get in same situation than this post will definitely save lot of the troubleshooting time that I wasted in finding the cause.
Thanks for reading and following.