You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am leveraging Invoke-Parallel to process VM actions in parallel in an Azure Automation runbook:
$AzureRMVMs | Invoke-Parallel -ScriptBlock {
$ARMVM = $PSItem
$VMStatus = $ARMVM | Get-AzureRmVM -Status | Select-Object Name, @{n = 'PowerState'; e = {($PSItem.Statuses | Where-Object Code -Like "*PowerState*").DisplayStatus}}
switch ($using:VMAction) {
'Start' {
if ($VMStatus.PowerState -ne 'VM running') {
Write-Output "VM $($ARMVM.Name) is not running - starting"
$ARMVM | Start-AzureRmVM
} else {
Write-Output "VM $($ARMVM.Name) is already running - no action triggered"
}
}
'Stop' {
if ($VMStatus.PowerState -eq 'VM running') {
Write-Output "VM $($ARMVM.Name) is running - stopping"
$ARMVM | Stop-AzureRmVM -Force
} else {
Write-Output "VM $($ARMVM.Name) is already stopped - no action triggered"
}
}
'Default' {Write-Output "VM Action $($using:VMAction) not defined in runbook, no action taken"}
}
} -RunspaceTimeout 300 -NoCloseOnTimeout
This works as expected, however, the following error is generated in the error stream:
Get-RunspaceData : Collection was modified; enumeration operation may not execute.
At Invoke-Parallell 542 char:13
I am leveraging Invoke-Parallel to process VM actions in parallel in an Azure Automation runbook:
This works as expected, however, the following error is generated in the error stream:
Get-RunspaceData : Collection was modified; enumeration operation may not execute.
At Invoke-Parallell 542 char:13
Any idea what might be causing this?
The text was updated successfully, but these errors were encountered: