Get-AzureADUser与2过滤器?



如何过滤Get-AzureADUser的两个值?

因此,对于以下内容,我可以搜索以Student开头的DisplayName但我也希望返回UserPrincipalName也包含"@somedomain.com">

的值
Get-AzureADUser -Filter "startswith(DisplayName,'student')"

我不认为这可以只与-Filter。由于oData v3过滤器不支持进行部分匹配的运算符(使用matchlike),因此您必须依赖内置函数。看来你不能在-Filter中使用endswith()substringof()功能。您需要使用Where-Object来进一步过滤。

Get-AzureADUser -Filter "startswith(DisplayName,'student')" -All:$true |
Where UserPrincipalName -like '*@somedomain.com'

我使用Azure Cloud shell测试了多个场景。

# Error
Get-AzureADUser -Filter "startswith(displayname,'student') and endswith(displayname,'student')"
# Error
Get-AzureADUser -Filter "startswith(displayname,'student') and endswith(UserPrincipalName,'@domain.com')"
# Error
Get-AzureADUser -Filter "(startswith(displayname,'student')) and (endswith(UserPrincipalName,'@domain.com'))"
# Error
Get-AzureADUser -Filter "endswith(UserPrincipalName,'@domain.com')"
# Error
Get-AzureADUser -Filter "substringof('@domain.com',UserPrincipalName)"
# No Errors
Get-AzureADUser -Filter "startswith(displayname,'student') and startswith(UserPrincipalName,'student')"

最新更新