Skip to content

continue keyword causes System Error #3117

@danielniccoli

Description

@danielniccoli

Describe the bug

The following code throws an error Get-MgGroupMember_List: System error. due to the continue keyword in the ForEach-Object:

$members = Get-MgGroupMember -GroupId $groupId -All | ForEach-Object {
    # Skip some users
    if($_.Id -eq "7ac26e6b-0fc8-47b2-9e96-20326525db9c") {
        continue
    }

    $_ 
}

I am aware that I can work around the bug by putting my logic inside the if-statement.

Expected behavior

The use of the continue keyword should not cause an exception, as shown below:

@(1,2,3) | % {
    if($_ -eq 2) { continue }
    $_
}

How to reproduce

See above

SDK Version

No response

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions