I started using the AzureADPreview module because I wanted a faster way to activate my Privileged Identity Management Azure AD roles. This module has all of the Microsoft Graph support for me to activate and schedule my roles, but I’ve found that I still need to leverage Windows PowerShell for it to work.
Problem 1: Installing the module with PowerShell 7
If I try to just simply install the module and load it with PowerShell 7, there are no obvious issues. However, when I try to run
Connect-AzureAD, I get this error:
Connect-AzureAD: One or more errors occurred. (Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b77a5c561934e089'.) Connect-AzureAD: Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Problem 2: Importing the module with WinPSCompat
If I try to import the module using
Import-Module -Name AzureADPreview -UseWindowsPowerShell, this seems to resolve the issue for problem 1 (i.e., I can successfully run
Connect-AzureAD). However, now I cannot actually create the schedule object required to activate the role. When I try to run
New-Object -TypeName Microsoft.Open.MSGraph.Model.AzureADMSPrivilegedSchedule I get this error:
New-Object: Cannot find type [Microsoft.Open.MSGraph.Model.AzureADMSPrivilegedSchedule]: verify that the assembly containing this type is loaded.
Here’s a reference to this object and why I’m trying to use it: Open-AzureADMSPrivilegedRoleAssignmentRequest - Example 1
Problem 3: I cannot solve problem 1 and problem 2 simultaneously
After encountering problem 2, I went back to problem 1 and found that I can successfully create a schedule object when importing the module without WinPSCompat. So this is ultimately where I’m stuck. I know how I can work around connecting to Azure AD and I know how I can work around the scheduled object, but I don’t know how to handle both and be successful.
With the release of version 2.0.4-Preview2 of the ExchangeOnlineManagement module that introduces PowerShell 7 support, I’ve been very interested in trying to solve this last problem with Azure AD so that I can leave Windows PowerShell behind for the majority of my daily work. Thank you in advance for your help and support!