23 November 2016

ExportO365UserInfo.ps1 | You cannot call a method on a null-valued expression

Recently I was performing an Office 365 migration for a client who's on premise Exchange environment was 2007.  Once I had migrated the mail boxes, I needed to convert the users to Mail Enabled Users (MEUs).  This is explained on Microsoft's website here.

There are two scripts you're required to run.  When you're running the first one, which is ExportO365UserInfo.ps1, the MS website states you need to do this from EMS.  This is incorrect.  If you run this script from EMS, you will get the following error message:

You cannot call a method on a null-valued expression.
At C:\migrace\ExportO365UserInfo.ps1:53 char:52
+             $CloudEmailAddress = $CloudEmailAddress.ToString <<<< ().ToLower(
).Replace('smtp:', '')
    + CategoryInfo          : InvalidOperation: (ToString:String) [], RuntimeE
   xception
    + FullyQualifiedErrorId : InvokeMethodOnNull


In order to get around this, and to make the scirpt work, simply run this in normal Powershell instead of EMS.  It will work well and it will create the required cloud.csv file.




Once you've done that, you can run the second command within EMS for it to work well. 

Winthrop Australia provides IT Support and Consultancy in the Perth area.

1 comment: