The Advanced Settings for Microsoft Exchange 2010/13 and Office 365 include the ability to run PowerShell scripts that can be run at various stages of the migration if required. Running scripts is optional and can be used to perform advanced configuration and settings if your environment requires.
You may also need to run the following command in PowerShell before running any other commands:
Set-ExecutionPolicy RemoteSigned as Administrator, or
Set-ExecutionPolicy Unrestricted CurrentUser as the user you will be logged in as when running the CloudM Migrate.
PowerShell scripts do not have to be run and the default scripts are used to check for users and create users in Office 365 if they do not exist. For example, if you have the following conditions, you do not need to run any scripts: your users already exist in the destination system; you know the primary SMTP address for each user and have set the correct ‘import name’ for each user. In this case then you can simply set the PowerShell scripts to never run (set ‘Init’ and ‘Before’ scripts to ‘Never’). All scripts can be disabled by setting the appropriate ‘Run’ setting for the script to ‘Never’.
Scripts are usually run at the beginning of a migration to Exchange 2010/Office 365 to determine if users exist in the system being migrated to and to create them if required. Settings for PowerShell scripts can be found in ‘Destination Platform Migration Settings->Office 365/Exchange 2007/2010/2013/2016′:
Scripts are run at various points in a migration:
- PowerShell Init Script – a script run once at the start of a migration. This is usually used to set up the PowerShell and environment. The default script sets up a session with Microsoft Office 365. If you are migrating to Exchange 2010 on-premise, the script needs to be changed. If you are running CloudM Migrate on the same machine as an Exchange installation then the init script can be omitted
- PowerShell Before Script – a script run for every user at the start of a user migration. This script is normally used to check if a user account exists in the destination system and to create it if not. The default script is for Office 365 and if you are migrating to Exchange 2010 on-premise, the script needs to be changed.
- PowerShell After Script – a script run for every user at the end of a user migration. There is no default setting for this script.
- PowerShell Finalize Script – a script once when the migration for all users is complete. There is no default setting for this script.
The tool determines whether a script has run successfully if no exception is thrown from the script. In PowerShell, internal cmdlets handle their own errors unless instructed to do so in the script. It is usually important to include the global statement
$ErrorActionPreference = 'Stop', in the script.
You can also throw your own custom exception from scripts if required which will then be displayed in the user interface and trace files.
PowerShell Scripting for Specific Platforms
Depending on the version of Exchange you are migrating to, the default scripts may need to be changed. See the following articles for example scripts:
Use of Replacement Variables in PowerShell Scripts
It is possible to make use of PowerShell replacement variables to enhance the scripting capabilities of CloudM Migrate.