Microsoft Graph PowerShell v1 to v2 migration toolkit

Carol Mbasinge Kigoonya

Microsoft Graph PowerShell v2 introduces changes that will require v1 users to change their scripts to address issues like naming conventions of command names if their scripts include directives for switching to beta profile.

To aid users in updating from Microsoft Graph PowerShell v1 to v2 we have a Migration Toolkit that identifies and resolves breaking changes.

The Migration Toolkit has various capabilities depending on the arguments provided. For all the scenarios, the output from the toolkit will give you suggestions on where to change your script. The “Location” column shows the script name and the line number while the “Original” and “After” columns show the current commands and the new suggested commands respectively.

Examples

Scenario 1: Identify changes on your script that has both profiles (v1 & Beta profiles)

New-MgMigrationPlan -FilePath “<Location to your script>”

In the example below all commands under “Select-MgProfile -Name ‘beta’” will have commands updated with the Beta prefix.

A screen shot of a computer Description automatically generated with medium confidence

Scenario 2: Identify changes on a script to utilize one endpoint (either beta or V1) using -GraphProfile

New-MgMigrationPlan -FilePath “<Location to your script>” -GraphProfile Beta

This will subject the whole script to the naming convention of commands as per expectations with PowerShell v2

A black screen with white text Description automatically generated with low confidence

Scenario 3: Identify changes on a script and generate a new v2 compliant script.

New-MgMigrationPlan -FilePath “<Location to your script>” -UpdatedFilePath “Path to new generated script”

In this scenario, the toolkit provides the user an option of generating a new script with the new suggested changes to the provided path.

A screen shot of a computer Description automatically generated with medium confidence

Graphical user interface, text, application Description automatically generated

Scenario 4: Identify changes on a script(s) in a directory and generate a new v2 compliant script (s) in a new directory.

New-MgMigrationPlan -Directory “<Directory to your script>” -UpdatedFilePath “Path to new generated script”

In this scenario, the toolkit provides the user an option of generating a new scripts for a directory with the new suggested changes to the provided path. Files will be appended with a ‘Migration-‘ prefix on the script names.

A screenshot of a computer program Description automatically generated with medium confidence

A screenshot of a computer Description automatically generated with low confidence

Next steps

Check out this documentation for details on breaking changes, fixes and guidance through the migration that an SDK user might run while upgrading to v2 as well as provide examples for implementing the new features, helping you quickly take advantage of all the new capabilities.

Add the new SDK for Microsoft Graph v1.0 module to your project. You can have a side-by-side installation by running the following command in the Package Manager Console or replace the Microsoft Graph PowerShell SDK installed by removing -AllowClobber:

Install-Module Microsoft.Graph -AllowClobber -Force

Or for Microsoft Graph beta module:

Install-Module Microsoft.Graph.Beta -AllowClobber -Force

Follow us on Twitter @Microsoft365Dev for the latest announcements and resources.

Happy coding!

0 comments

Discussion is closed.

Feedback usabilla icon