{"id":14566,"date":"2023-07-06T08:00:29","date_gmt":"2023-07-06T15:00:29","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/?p=14566"},"modified":"2023-07-06T09:38:59","modified_gmt":"2023-07-06T16:38:59","slug":"microsoft-graph-powershell-v1-to-v2-migration-toolkit","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/microsoft-graph-powershell-v1-to-v2-migration-toolkit\/","title":{"rendered":"Microsoft Graph PowerShell v1 to v2 migration toolkit"},"content":{"rendered":"<p>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.<\/p>\n<p>To aid users in updating from Microsoft Graph PowerShell v1 to v2 we have a <a href=\"https:\/\/www.powershellgallery.com\/packages\/Microsoft.Graph.Migration.Tool\/1.0.0\">Migration Toolkit<\/a> that identifies and resolves breaking changes.<\/p>\n<p>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 \u201cLocation\u201d column shows the script name and the line number while the \u201cOriginal\u201d and \u201cAfter\u201d columns show the current commands and the new suggested commands respectively.<\/p>\n<h2>Examples<\/h2>\n<p><strong>Scenario 1: Identify changes on your script that has both profiles (v1 &amp; Beta profiles)<\/strong><\/p>\n<p><code>New-MgMigrationPlan -FilePath \u201c&lt;Location to your script&gt;\u201d<\/code><\/p>\n<p><em>In the example below all commands under \u201cSelect-MgProfile -Name \u2018beta\u2019\u201d will have commands updated with the Beta prefix.<\/em><\/p>\n<p><strong><img decoding=\"async\" width=\"1945\" height=\"400\" class=\"wp-image-14567\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic.png\" alt=\"A screen shot of a computer Description automatically generated with medium confidence\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic.png 1945w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-300x62.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-1024x211.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-768x158.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-1536x316.png 1536w\" sizes=\"(max-width: 1945px) 100vw, 1945px\" \/><\/strong><\/p>\n<p><strong>Scenario 2: Identify changes on a script to utilize one endpoint (either beta or V1) using -GraphProfile <\/strong><\/p>\n<p><code>New-MgMigrationPlan -FilePath \u201c&lt;Location to your script&gt;\u201d -GraphProfile Beta<\/code><\/p>\n<p><em>This will subject the whole script to the naming convention of commands as per expectations with PowerShell v2 <\/em><\/p>\n<p><strong><img decoding=\"async\" width=\"1869\" height=\"397\" class=\"wp-image-14568\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-black-screen-with-white-text-description-automa.png\" alt=\"A black screen with white text Description automatically generated with low confidence\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-black-screen-with-white-text-description-automa.png 1869w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-black-screen-with-white-text-description-automa-300x64.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-black-screen-with-white-text-description-automa-1024x218.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-black-screen-with-white-text-description-automa-768x163.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-black-screen-with-white-text-description-automa-1536x326.png 1536w\" sizes=\"(max-width: 1869px) 100vw, 1869px\" \/><\/strong><\/p>\n<p><strong>Scenario 3: Identify changes on a script and generate a new v2 compliant script. <\/strong><\/p>\n<p><code>New-MgMigrationPlan -FilePath \u201c&lt;Location to your script&gt;\u201d -UpdatedFilePath \u201cPath to new generated script\u201d<\/code><\/p>\n<p><em>In this scenario, the toolkit provides the user an option of generating a new script with the new suggested changes to the provided path.<\/em><\/p>\n<p><strong><img decoding=\"async\" width=\"1950\" height=\"414\" class=\"wp-image-14569\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-1.png\" alt=\"A screen shot of a computer Description automatically generated with medium confidence\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-1.png 1950w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-1-300x64.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-1-1024x217.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-1-768x163.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screen-shot-of-a-computer-description-automatic-1-1536x326.png 1536w\" sizes=\"(max-width: 1950px) 100vw, 1950px\" \/><\/strong><\/p>\n<p><strong><img decoding=\"async\" width=\"1711\" height=\"460\" class=\"wp-image-14570\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/graphical-user-interface-text-application-descr.png\" alt=\"Graphical user interface, text, application Description automatically generated\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/graphical-user-interface-text-application-descr.png 1711w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/graphical-user-interface-text-application-descr-300x81.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/graphical-user-interface-text-application-descr-1024x275.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/graphical-user-interface-text-application-descr-768x206.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/graphical-user-interface-text-application-descr-1536x413.png 1536w\" sizes=\"(max-width: 1711px) 100vw, 1711px\" \/><\/strong><\/p>\n<p><strong>Scenario 4: Identify changes on a script(s) in a directory and generate a new v2 compliant script (s) in a new directory. <\/strong><\/p>\n<p><code>New-MgMigrationPlan -Directory \u201c&lt;Directory to your script&gt;\u201d -UpdatedFilePath \u201cPath to new generated script\u201d<\/code><\/p>\n<p><em>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 \u2018Migration-\u2018 prefix on the script names.<\/em><\/p>\n<p><img decoding=\"async\" width=\"2224\" height=\"1262\" class=\"wp-image-14571\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-program-description-au.png\" alt=\"A screenshot of a computer program Description automatically generated with medium confidence\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-program-description-au.png 2224w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-program-description-au-300x170.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-program-description-au-1024x581.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-program-description-au-768x436.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-program-description-au-1536x872.png 1536w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-program-description-au-2048x1162.png 2048w\" sizes=\"(max-width: 2224px) 100vw, 2224px\" \/><\/p>\n<p><strong><img decoding=\"async\" width=\"1666\" height=\"385\" class=\"wp-image-14572\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-description-automatica.png\" alt=\"A screenshot of a computer Description automatically generated with low confidence\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-description-automatica.png 1666w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-description-automatica-300x69.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-description-automatica-1024x237.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-description-automatica-768x177.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/07\/a-screenshot-of-a-computer-description-automatica-1536x355.png 1536w\" sizes=\"(max-width: 1666px) 100vw, 1666px\" \/><\/strong><\/p>\n<h2>Next steps<\/h2>\n<p>Check out this <a href=\"https:\/\/aka.ms\/graph\/sdk\/powershell\/upgrade-to-v2\">documentation<\/a> 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.<\/p>\n<p>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 <code>-AllowClobber<\/code>:<\/p>\n<p><code>Install-Module Microsoft.Graph -AllowClobber -Force<\/code><\/p>\n<p>Or for Microsoft Graph beta module:<\/p>\n<p><code>Install-Module Microsoft.Graph.Beta -AllowClobber -Force<\/code><\/p>\n<p>Follow us on Twitter\u00a0<a href=\"https:\/\/twitter.com\/Microsoft365Dev\">@Microsoft365Dev<\/a>\u00a0for the latest announcements and resources.<\/p>\n<p>Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n","protected":false},"author":117208,"featured_media":14578,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[149],"class_list":["post-14566","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph","tag-microsoft-graph-powershell-sdk"],"acf":[],"blog_post_summary":"<p>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.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/14566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/117208"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=14566"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/14566\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/14578"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=14566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=14566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=14566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}