首页 > 解决方案 > Powershell:如何从 Azure Active Directory 用户 (Get-AzADUser) 获取名称

问题描述

很简单的问题。我想从 Azure 的 Active Directory 中获取用户 john@doe.com 的名称。为此我使用了

$user = Get-AzADUser -UserPrincipalName "john@doe.com"

我现在该怎么办$user?根据微软的文档Get-AzADUser 返回一个 Microsoft.Azure.Commands.ActiveDirectory.PSADUser 对象。但是,Microsoft 无法链接到 PSADUser 的文档,我找不到。尝试通过键入来查看内容

$user

产量

Microsoft.Azure.Commands.ActiveDirectory.PSADUser

那么我现在如何才能看到这个对象内部的内容呢?还是我应该考虑一种完全不同的方法?

标签: powershellazure-active-directory

解决方案


如果您想获取 $user 详细信息以执行以下步骤

Connect-AzAccount

接下来运行 cmd 并复制特定用户的用户主体名称

Get-AzADUser

使用上面的 UserPrincipalName 作为下面的代码

 $user = Get-AzADUser -UserPrincipalName "Sruthi_xxx.live#EXT#@exchangetestdomain.onmicrosoft.com"

在此处输入图像描述


推荐阅读