question

Emanuele-0211 avatar image
0 Votes"
Emanuele-0211 asked Monalla-MSFT commented

Powershell Workflow with nested foreach

Hi all,

i'm writing a script to remove and recreate eventhub and private endpoint on Azure. I'm testing the loop before to proceed but had a problem with nested foreach inside a parallel foreach:

     workflow test-evh
 {
    
 $connectionResult = Connect-AzAccount -Identity
 $connectionResult
    
        
 $EvhExclusion = 'myevh'
    
    
     $EvhLists = Get-AzEventHubNamespace
     $PendsEvh = Get-AzPrivateEndpoint
        
     foreach -parallel -ThrottleLimit 10 ($EvhList in $EvhLists)
         {           
         if ($EvhList.Name -notin $EvhExclusion){    
            if ($EvhList.Location -eq "North Europe"){
                    
             foreach ($PendEvh in $PendsEvh)
             {           
    
             if ($PendEvh.PrivateLinkServiceConnections.GroupIds -eq "namespace" -and $PendEvh.Location -eq "northeurope" -and $PendEvh.PrivateLinkServiceConnections.PrivateLinkServiceId -in $EvhList.Id ){
    
              Write-Output   $PendEvh.Name
                
             }
    
               
             }
    
             Write-Output $EvhList.Name
    
         }
     }
 }
    
 }

script work but i got only eventhub namespace. If i run it outside workflow and without parallel, it works and i got both private endpoint and namespace.

What i'm doing wrong?

Thanks

azure-automation
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Emanuele-0211 - Did the below answer help resolve your issue, if not please revert back with any questions.
and if it did, please feel free to "accept as answer" so it can be beneficial to the community.

0 Votes 0 ·

1 Answer

Monalla-MSFT avatar image
0 Votes"
Monalla-MSFT answered

@Emanuele-0211 - Thanks for reaching out.

I believe the location does not have a space in it.

193221-image.png

193222-image.png


Hope this helps. and please feel free to reach out if you have any further questions.



If the above response was helpful, please feel free to "Accept as Answer" and "Upvote" the same so it can be beneficial to the community.



image.png (81.4 KiB)
image.png (54.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.