azure - 如何将数组项中的项传递给使用过滤器的powershell命令

标签 azure powershell

accounts=$(az ad sp list --show-mine --query [].appDisplayName -otsv)

这会给我一个数组

我想将每个项目传递到此命令中的数组

foreach ($myApp in $accounts){
Get-AzureADApplication -Filter "DisplayName eq $myApp"
}

当我尝试这个时,我在位置处出现语法错误 这可能吗

我是 powershell 新手

最佳答案

您是否尝试过将变量括在单引号中?

根据文档,过滤器中的值被引用:

https://learn.microsoft.com/en-us/powershell/module/azuread/get-azureadapplication?view=azureadps-2.0#example-1-get-an-application-by-display-name

foreach ($myApp in $accounts){
    Get-AzureADApplication -Filter "DisplayName eq '$myApp'"
}

关于azure - 如何将数组项中的项传递给使用过滤器的powershell命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72661949/

相关文章:

powershell - 如何在 PowerShell 中注释掉代码?

Powershell : Remote Exception and NativeCommandError 中的 Python 脚本

Powershell 命令将断开连接的用户踢出服务器

powershell - PowerShell 中的函数返回值

azure - 将 Azure Web App Files 文件夹装载到 VM 中?

php - Azure 上的 Laravel 应用程序 : Access denied for user 'azure' @'localhost'

Java - 如何从 Android 中的 azure 移动服务检索和使用单个值

java - Azure KeyVault : How to add Spring properties with hypehen as secrets

azure - 想要创建 Azure 逻辑应用表达式

powershell - Get-AzureRmADApplication 显示没有权限