The term 'Connect-AzureAD' is not recognized as the name of a cmdlet The term 'Connect-AzureAD' is not recognized as the name of a cmdlet powershell powershell

The term 'Connect-AzureAD' is not recognized as the name of a cmdlet


I had an issue with PowerShell v7, unlike PS v5, you have to import the module after installation with Import-Module AzureAD. The error is identical to if you haven't imported it after installing it from a module source like PSGallery.


@user1638526 As mike mentioned, you should install the AzureAD module first.

You can follow the below steps:

Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -ForceImport-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201Install-Module AzureAD -Force

-Force suppresses the user input prompts and allows the script to run in the background.

Reference: How do I install the Nuget provider for PowerShell on a unconnected machine so I can install a nuget package from the PS command line?

About for how to call PowerShell command or PS1 file using C# you can also refer to link or another SO Thread.

Hope this helps!