首页 > 解决方案 > 无法识别 Connect-AzureAd

问题描述

我试图让这个命令在我的 MAC 操作系统上运行,甚至安装我在其他博客中找到的所有模块,比如 AzureAD、AzureADPreview.¨。我仍然收到同样的信息。有人可以给我一些关于修复的线索吗?

Connect-AzureAD: The term 'Connect-AzureAD' 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.

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Darwin 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

标签: azurepowershell

解决方案


您收到一条提示无法识别 cmdlet 的错误消息的事实表明您尚未安装或导入正确的模块。关于通常不使用AzureAD 模块的重要注意事项,您通常应该尽可能地使用AZ 模块

如果您特别想使用,AzureAD那么使用可以使用以下

Register-PackageSource -Trusted -ProviderName 'PowerShellGet' -Name 'Posh Test Gallery' -Location https://www.poshtestgallery.com/api/v2/
Install-Module AzureAD.Standard.Preview
import-Module AzureAD.Standard.Preview

我建议您使用以下AZ Module方法:

Install-Module az
Import-Module az

connect-azureAD对于您可以使用的 cmdletconnect-azaccount

因为您使用的是 Mac,您将不会遇到 Windows 提示登录,您将获得一个链接,您需要手动使用该链接登录以进行身份​​验证。


推荐阅读