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

[玩转系统] Get-MsolUser - 在 PowerShell 中获取所有 Msol 用户

作者:精品下载站 日期:2024-12-14 06:24:48 浏览:15 分类:玩电脑

Get-MsolUser - 在 PowerShell 中获取所有 Msol 用户


PowerShell 中的 Get-MsolUser cmdlet 从 Azure Active Directory 获取单个用户或用户列表。 Get-MsolUser 命令获取所有用户属性,例如 DisplayName、IsLicensed、UserPrincipalName 等...

下面给出了获取 Office 365 中用户列表的语法。

Get-MsolUser

此命令返回 Office 365 或 Azure Active Directory 中的所有用户。

[玩转系统] Get-MsolUser - 在 PowerShell 中获取所有 Msol 用户

在本文中,我们将讨论如何使用 PowerShell 中的 Get-MsolUser cmdlet 获取 Azure AD 中的用户列表、获取已启用的用户、通过用户原则名称获取用户、通过搜索字符串获取用户、获取许可用户列表以及获取未经许可的用户列表。

如何在 PowerShell 中获取 Office 365 中的所有用户

若要获取 Office 365 或 Azure Active Directory 中的所有用户,请使用 Get-MsolUser cmdlet。

Get-MsolUser

此命令检索组织中的所有用户。它最多显示默认值 500 个结果。

要在 Office 365 中获取超过 500 个用户,请使用带有 -All-MaxResults 参数的 Get-MsolUser 命令。

# Retrieves more than 500 users in the company
Get-MsolUser -All

# Specify maximum result to retrieve number of users in the company
Get-MsolUser -MaxResults 2000

如何显示 MsolUser 的所有属性

使用 PowerShell 中的 Get-MsolUser cmdlet 显示 Microsoft Office 365 中用户的所有属性。此命令使用 UserPrincipalName 参数从 Azure Active Directory 检索用户对象。

Get-MsolUser -UserPrincipalName "[email " | FL

在上面的 PowerShell 脚本中,Get-MsolUser cmdlet 检索用户对象“[email ”并使用 Format-List cmdlet设置 Get-MsolUser cmdlet 的输出格式并显示用户的所有属性。

上述 PowerShell 脚本的输出显示 Office 365 中 Msol 用户的所有属性。

[玩转系统] Get-MsolUser - 在 PowerShell 中获取所有 Msol 用户

如何在 PowerShell 中获取 Office 365 中启用的用户

要在 PowerShell 中获取 Office 365 中启用的用户,请使用带有 EnabledFilter 参数的 Get-MsolUser 命令来仅检查公司中的 EnabledOnly 用户。

Get-MsolUser -EnabledFilter EnabledOnly -MaxResults 1000

在上面的 PowerShell 脚本中,PowerShell 中的 Get-MsolUser cmdlet 使用 EnabledFilter 参数来筛选公司中的 EnabledOnly 用户。该命令使用 MaxResults 参数获取最多 1000 个启用的用户。

如何使用 PowerShell 在 Office 365 中通过 UserPrincipalName 获取用户

要在 Office 365 中通过 UserPrincipalName 获取用户,请使用带有 UserPrincipalName 参数的 Get-MsolUser cmdlet。

Get-MsolUser -UserPrincipalName "[email " 

在上述 PowerShell 脚本中,Get-MsolUser cmdlet 使用 UserPrincipalName 参数指定用户主体名称“[email ”并检索详细信息有关 Office 365 中用户的信息。

下面给出了上述通过 userprincipalname 查找用户的 PowerShell 脚本的输出。

[玩转系统] Get-MsolUser - 在 PowerShell 中获取所有 Msol 用户

如何在 Azure Active Directory 中通过搜索字符串搜索用户

要在 Azure Active Directory 中通过搜索字符串搜索用户,请在 PowerShell 中使用带有 SearchString 参数的 Get-MsolUser cmdlet。

SearchString 参数指定一个字符串,以匹配以此字符串开头的电子邮件地址或显示名称。

Get-MsolUser -SearchString "samer"

在上面的 PowerShell 脚本中,Get-MsolUser 命令检索显示名称或电子邮件地址中包含“samer”的用户列表。

下面给出了上述通过搜索字符串获取用户的 PowerShell 脚本的输出。

PS C:\WINDOWS\system32> Get-MsolUser -SearchString "samer"                                                              
UserPrincipalName                  DisplayName    isLicensed
-----------------                  -----------    ----------
[email  samer amberson True


PS C:\WINDOWS\system32>  

如何通过对象 ID 获取用户

在 PowerShell 中使用 Get-MsolUser cmdlet 和 ObjectId 参数指定用户的对象 ID,以按对象 ID 获取用户。

Get-MsolUser -ObjectId 1f149c47-a670-4f12-a4ac-01423cbafb58 

此命令检索具有指定对象 ID 的用户。

下面给出了上述通过对象 ID 查找用户的 PowerShell 脚本的输出。

PS C:\WINDOWS\system32> Get-MsolUser -ObjectId 1f149c47-a670-4f12-a4ac-01423cbafb58                                     
UserPrincipalName                 DisplayName isLicensed
-----------------                 ----------- ----------
[email  gary edler  False


PS C:\WINDOWS\system32>        

结论

希望上述有关如何在 PowerShell 中使用 Get-MsolUser cmdlet 获取 Office 365 中的所有用户并显示用户的所有属性的文章对您有所帮助。

您可以在 ShellGeek 主页上找到有关 PowerShell Active Directory 命令和 PowerShell 基础知识的更多主题。

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

取消回复欢迎 发表评论:

关灯