gpt4 book ai didi

azure - 如何为 Get-AzureADUserAppRoleAssignment 创建循环?

转载 作者:行者123 更新时间:2023-12-03 05:42:40 26 4
gpt4 key购买 nike

我想制作一个 powershell 脚本,该脚本将列出 Azure AD 中的用户列表以及分配给列表中每个用户的所有企业应用程序。

我尝试设置 ForEach-Object 循环来迭代从 Get-AzureADUser 获取的每个对象

此代码有效:

$UserId = (Get-AzureADUser -Top 1).ObjectId
Get-AzureADUserAppRoleAssignment -ObjectId $UserId

我正在尝试对每个输出进行循环和迭代:

$UserId = (Get-AzureADUser).ObjectId | ForEach-Object {
Get-AzureADUserAppRoleAssignment -ObjectId $UserId}

这是错误消息:

Get-AzureADUserAppRoleAssignment:无法将“System.Object[]”转换为参数“ObjectId”所需的类型“System.String”。不支持指定的方法。行:1 字符:44+ 获取-AzureADUserAppRoleAssignment -ObjectId $UserID+ ~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-AzureADUserAppRoleAssignment],ParameterBindingException +FullyQualifiedErrorId:CannotConvertArgument,Microsoft.Open.AzureAD16.PowerShell.GetUserAppRoleAssignments

最佳答案

您可以通过以下命令为 Get-AzureADUserAppRoleAssignment 创建循环:

$UserId = (获取-AzureADUser).ObjectId

foreach($UserId 中的 $eachUserId){ 获取-AzureADUserAppRoleAssignment -ObjectId $eachUserId}

关于azure - 如何为 Get-AzureADUserAppRoleAssignment 创建循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57455483/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com