Here are the steps to install and import the module:
- Open PowerShell as an administrator.
- Run the following command to install the Azure Active Directory PowerShell module:
Install-Module AzureAD
If prompted to install the NuGet provider, type “Y” and press Enter.
Once the module is installed, run the following command to import it:Import-Module AzureAD
This will prompt you to enter your admin credentials. Once you enter your credentials, you should be connected to your Microsoft 365 tenant.
After completing these steps, you can use the Connect-MsolService cmdlet without receiving an error. Note that the Azure Active Directory PowerShell module provides similar functionality to the Microsoft Azure Active Directory Module for Windows PowerShell but with some differences in the cmdlet names and parameters.
If you receive an error message that says ” Connect-AzureAD: One or more errors occurred. (Could not load type ‘System.Security.Cryptography.SHA256Cng’ from assembly ‘System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.): Could not load type ‘System.Security.Cryptography.SHA256Cng’ from assembly ‘System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.Connect-AzureAD: One or more errors occurred. (Could not load type ‘System.Security.Cryptography.SHA256Cng’ from assembly ‘System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.)
Connect-AzureAD: Could not load type ‘System.Security.Cryptography.SHA256Cng’ from assembly ‘System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.
Connect-AzureAD: One or more errors occurred. (Could not load type ‘System.Security.Cryptography.SHA256Cng’ from assembly ‘System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.): Could not load type ‘System.Security.Cryptography.SHA256Cng’ from assembly ‘System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.”
Here are some steps you can try to resolve the issue:
- Ensure that your computer is up-to-date with the latest Windows updates.
- Check the .NET framework version installed on your computer. The AzureAD PowerShell module requires .NET Framework 4.7.2 or later. You can check the .NET framework version by running the following command in PowerShell:
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Get-ItemProperty -Name Version -EA 0 | Where-Object { $_.PSChildName -Match '^(?!S)\p{L}'} | Select-Object Version
This command may take some time to complete and will require an internet connection.
After completing these steps, connect to your Microsoft 365 tenant again using the Connect-AzureAD cmdlet. If the issue persists, you may need to contact Microsoft support for further assistance.