workflow Powershell
Hello
Please support
]2
Port is taken....


I product that problem is related with the Ideinty that cannot work with the Subsiption in Automation account
Part of my code :
workflow test3
{
Param
(
[Parameter(Mandatory= $True)]
[String] $GroupName,
[Parameter(Mandatory= $True)]
[String] $DestinationEmailAddress
)
"Log"
log AccountId
$UserManagedIdentityAccountId = "XYZ"
$Disable-AzContextAutosave -Scope Process
$AzureContext = (Connect-AzAccount -AccountId $UserManagedIdentityAccountId).context
$AzureContext = Set-AzContext -SubscriptionName $AzureContext.Subscription -DefaultProfile $AzureContext
log AccountId
"Test1"
Connect-AzAccount -AccountId $UserManagedIdentityAccountId
"Test2"
Connect-AzureAD -AccountId $UserManagedIdentityAccountId
"Test3"
### Scipt Block Query
$UserManagedIdentityAccountId = "XYZ"
$groups = Get-AzADGroup -SearchString $GroupName
$Exp = foreach($group in $groups){
$GroupId = $group.Id
$GroupName = $group.DisplayName
Get-AzADGroupMember -ObjectId $GroupId | Select-Object -Property @{Name = 'GroupName'; Expression= {$GroupName}}, DisplayName,Id
Write-Output $Exp
}
}