你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Get-AzureADUser

获取用户。

语法

GetQuery (默认值)

Get-AzureADUser
    [-All <Boolean>]
    [-Top <Int32>]
    [-Filter <String>]
    [<CommonParameters>]

GetVague

Get-AzureADUser
    [-SearchString <String>]
    [-All <Boolean>]
    [<CommonParameters>]

GetById

Get-AzureADUser
    -ObjectId <String>
    [-All <Boolean>]
    [<CommonParameters>]

说明

Get-AzureADUser cmdlet 从Microsoft Entra ID 获取用户。

示例

示例 1:获取前十名用户

PS C:\>Get-AzureADUser -Top 10

此命令获得 10 个用户。

示例 2:按 ID 获取用户

PS C:\>Get-AzureADUser -ObjectId "testUpn@tenant.com"

此命令获取指定的用户。

示例 3:在检索到的用户中搜索

PS C:\> Get-AzureADUser -SearchString "New"

ObjectId                             DisplayName UserPrincipalName                   UserType
--------                             ----------- -----------------                   --------
5e8b0f4d-2cd4-4e17-9467-b0f6a5c0c4d0 New user    NewUser@contoso.onmicrosoft.com     Member
2b450b8e-1db6-42cb-a545-1b05eb8a358b New user    NewTestUser@contoso.onmicrosoft.com Member

此 cmdlet 获取与 SearchString 值与 DisplayName 或 UserPrincipalName 中的第一个字符匹配的所有用户。

示例 4:按 userPrincipalName 获取用户

PS C:\>Get-AzureADUser -Filter "userPrincipalName eq 'jondoe@contoso.com'"

此命令获取指定的用户。

示例 5:按 JobTitle 获取用户

PS C:\>Get-AzureADUser -Filter "startswith(JobTitle,'Sales')"

此命令获取职位名称以销售开头的所有用户,例如销售经理和销售助理。

参数

-All

如果为 true,则返回所有用户。 如果为 false,则返回 Top 参数指定的对象数

参数属性

类型:Boolean
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Filter

指定 OData v3.0 筛选器语句。 此参数控制返回哪些对象。 有关使用 OData 进行查询的详细信息,请参见此处。 http://www.odata.org/documentation/odata-version-3-0/odata-version-3-0-core-protocol/#queryingcollections。 目前并非所有 OData v3.0 函数和运算符都受支持。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

GetQuery
Position:Named
必需:False
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ObjectId

在 Microsoft Entra ID 中指定用户的 ID(作为 UPN 或 ObjectId)。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

GetById
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-SearchString

指定搜索字符串。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

GetVague
Position:Named
必需:False
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Top

指定要返回的最大记录数。

参数属性

类型:Int32
默认值:None
支持通配符:False
不显示:False

参数集

GetQuery
Position:Named
必需:False
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters

备注

请参阅 Get-AzureADUser 到 Microsoft Graph PowerShell 的迁移指南