The pitfalls of Microsoft Graph PowerShell SDK

Introduction

Today, I would like to talk about the pitfalls of Microsoft Graph PowerShell SDK. Microsoft has kept various engineers around the world on their toes in the last 1 1/2 weeks, as they have increasingly updated the individual Graph PowerShell modules or, in my opinion, made them worse.

In this short article I would like to explain the problem in a little more detail, as there is currently not too much to be found on the Internet and on the other hand I would like to take the opportunity to show why you should use certain versions and not always go for the latest.

Problem description

The major problem began with the release of Microsoft Graph PowerShell SDK version 2.14.0 on 17 February 2024. An issue was already reported in GitHub with version 2.13.1, which would indicate a possible future issue.

What exactly is the problem with versions from probably even 2.13.0 (according to testing in the lab)?
Microsoft has started to deliver additional response headers in your return value. If you are now working with arrays and have previously filtered for certain values, this will no longer work as of now, 29th February 2024 from Microsoft Graph PowerShell SDK version 2.13.0 on.

How can the problem be solved

As a workaround, I recommend switching to Microsoft Graph PowerShell SDK version 2.12.0 or older which is not affected by the additional response headers.

 > Install-Module -Name Microsoft.Graph -RequiredVersion 2.12.0
> Import-Module Microsoft.Graph -RequiredVersion 2.12.0

Note: If you use Azure DevOps, don’t forget the parameter -force, otherwise Azure DevOps does not let you install/import the module.

As we already know, Microsoft is working on a solution that allows the additional response headers to be explicitly queried as an additional parameter in newer versions.

Recommendation

This incident has once again shown how important it is to use PowerShell modules with versions.

The troubleshooting of such errors alone can take several days and then additionally adapting and testing all PS scripts is a very big hassle that you can save yourself if you define the module versions.

Versioning is no longer a foreign concept in software development, on the contrary, it is now a de facto standard. The same proven concept should also be applied in the DevOps area. If you are not yet using it, then I recommend that you use it after this incident, which you may also have been concerned about. This will save you a lot of trouble in the future.

The current timing of the problem with the Microsoft Graph PowerShell SDK is very unfortunate, as the old AzureAD and MSOL modules are retired as of 30 March 2024.

You might also like