In the world of software development, upgrading libraries and dependencies is often a necessity to keep up with evolving technologies, security patches, and enhanced functionalities.
However, in some cases, it’s not always straightforward to immediately jump to the latest version, especially when dealing with critical components like Microsoft Graph SDK.
Microsoft Graph SDK offers powerful capabilities for integrating Microsoft services into your applications. But what happens when you need to upgrade to a newer version while still maintaining compatibility with existing code? This is where the strategy of running older versions in parallel comes into play.
To upgrade Microsoft SDK use:
Install-Module Microsoft.Graph -AllowClobber -Force
Note: Microsoft has changed the beta module now you do not have to use Select-MgProfile beta
Just install the beta module
Install-Module Microsoft.Graph.Beta -AllowClobber -Force
Utilize cmdlets by adding beta keywords like:Get-MgBetaUser
Now problem comes after upgrade is that existing scripts where you have specifically used beta endpoint with below command starts failing.
Select-MgProfile beta
Error is àSelect-MgProfile: The term ‘Select-MgProfile’ is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
To resolve this issue, we have to utilize import module to load specific versions of the older graph module(v1) or fully check the script where Beta has been used and update it.
What we have done is updated our scripts as below to make them run in Parallel:
Earlier we were not using the import-module command as PowerShell was auto detecting the module but after upgrade it was always detecting the latest version because of which error was getting generated , we browsed to all our scripts that were using beta profile and updated in same way.
Another such script that was using device commands.
Now the question arises, why we have just not done below and loaded specific modules instead of whole ?
Import-Module Microsoft.Graph -RequiredVersion 1.18.0
We tried it but every time scripts run it takes more time on the import-module part which we did not like so we have utilized the specific modules that we are utilizing in the script.
Thanks for reading…
Tech Wizard
https://techwizard.cloud
https://syscloudpro.com/
PowerShell Fast Track