当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] Get-MsolUser :您必须调用 Connect-MsolService cmdlet

作者:精品下载站 日期:2024-12-14 20:55:36 浏览:15 分类:玩电脑

Get-MsolUser :您必须调用 Connect-MsolService cmdlet


[玩转系统] Get-MsolUser :您必须调用 Connect-MsolService cmdlet

使用 PowerShell 命令 Get-MsolUser 时,您有时会看到错误消息“您必须在调用任何其他 cmdlet 之前调用 Connect-MsolService cmdlet”。

输出可能与此类似:

PS C:\> Get-MsolUser -UserPrincipalName [email protected]
Get-MsolUser : You must call the Connect-MsolService cmdlet before calling
   any other cmdlets.
   At line:1 char:1
+ Get-MsolUser -UserPrincipalName [email protected]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [Get-MsolUser],
    MicrosoftOnlineException
    + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.
    MicrosoftOnlineException,Microsoft.Online.Administration.Automation.GetUser

此错误消息表明您尚未建立与 Azure AD 的连接。

要解决此问题,您必须使用 Connect-MsolService 命令进行连接,如下所示:

PS C:\> Connect-MsolService

(要了解如何一劳永逸地消除此类问题,请跳至本文的最后一部分)

此命令将启动 Azure AD 的身份验证过程。您输入的凭据指示您要连接到的 Azure AD 目录:

[玩转系统] Get-MsolUser :您必须调用 Connect-MsolService cmdlet

如果您输入的用户名和目录有效,则系统会要求您输入密码:

[玩转系统] Get-MsolUser :您必须调用 Connect-MsolService cmdlet

如果您的帐户启用了多重身份验证,系统会要求您输入验证令牌:

[玩转系统] Get-MsolUser :您必须调用 Connect-MsolService cmdlet

经过身份验证后,您可以重新运行 Get-MsolUser 命令,这次您应该会看到预期的结果:

PS C:\> Get-MsolUser -UserPrincipalName [email protected]

UserPrincipalName                    DisplayName          isLicensed
-----------------                    -----------          ----------
[email protected] morten skrubbeltrang True

PowerShell MSOnline 模块

Get-MSOLUser 命令是 MSOnline PowerShell 模块的一部分。

在某些情况下,您最终可能会并排安装多个版本的 MSOnline 模块。对正在加载的模块进行故障排除可能会非常令人困惑。

另外,在某些情况下,安装模块本身会引起一些麻烦。

如果您想了解有关 MSOnline 模块的安装和故障排除的更多信息,请查看本文。它包含 PowerShell 中模块加载顺序的完整说明。

轻松的 Office 365 管理

为了完全避免此类问题,您应该查看 Easy365Manager。

Easy365Manager 是熟悉的 AD 用户和计算机工具的扩展。

借助 Easy365Manager,您可以使用本机本地 AD 用户管理工具配置 Office 365 许可证和邮箱。因此,无需经常登录 AD Azure 门户和 Exchange 管理中心。

[玩转系统] Get-MsolUser :您必须调用 Connect-MsolService cmdlet

Easy365Manager 还使您能够摆脱本地 Exchange Server。这可以让您在短时间内节省大量时间和金钱。

在此下载免费且功能齐全的 30 天试用版。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯