Powershell replacement variables

What are PowerShell replacement variables and how are they used in CloudM Migrate?

Step-by-step guide

As described in this article, PowerShell scripts can be used to perform various tasks during a migration. Replacement variables can be seen in the default PowerShell scripts and provide a way to pass information from the CloudM Migrate configuration to the scripts. Replacement variables have the following format [!variable-name]. Before a script is run, these variables are replaced with their values. Several values are included with the tool and it is also possible to define your own.

The included variables and their values are:

  • [!admin-email] – The email address of the admin user
  • [!admin-password] – The password of the admin user
  • [!admin-domain] – The domain name being migrated to
  • [!user-exportname] – The export name of the user being migrated
  • [!user-importname] – The import name of the user being migrated
  • [!user-password] – The password of the user being migrated
  • [!user-givenname] – The given name of the user being migrated
  • [!user-familyname] -The family name of the user being migrated
  • [!ps-url] – https://ps.outlook.com/powershell

For example, the following is the default init PowerShell script:

# Open the connection
$sesh = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri [!ps-url] -credential (New-Object -TypeName System.Management.Automation.PSCredential -argumentlist '[!admin-email]',(ConvertTo-SecureString '[!admin-password]' -AsPlainText -Force)) -Authentication Basic -AllowRedirection
# Import the session
$imp = Import-PSSession -Session $sesh

This contains the replacement variables [!ps-url][!admin-email] and [!admin-password]. Before the script is run, these values will be replaced with the corresponding values from the configuration, giving a final script something like:

# Open the connection
$sesh = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -credential (New-Object -TypeName System.Management.Automation.PSCredential -argumentlist 'admin@cloudsolutions.co.uk',(ConvertTo-SecureString 'myR34llyG00dP@55w0rd' -AsPlainText -Force)) -Authentication Basic -AllowRedirection
# Import the session
$imp = Import-PSSession -Session $sesh

To define your own replacement variables use the setting ‘PowerShell Variables’ in the Office 365 / Exchange destination migration settings.

Multiple_Values.PNG

Was this article helpful?
1 out of 1 found this helpful