Forum Discussion

LainRobertson's avatar
LainRobertson
Silver Contributor
Aug 18, 2025

Bug: Invoke-MgGraphRequest not respecting ErrorAction.

Hi folks,

 

This is a brief callout that Invoke-MgGraphRequest is not currently respecting the ErrorAction parameter. Rather, it's hardwired to throwing an exception as if ErrorAction:Stop had been provided.

 

If you're like me and typically use ErrorAction:Stop in a try/catch block then you won't be impacted, but if use another value like Continue (the default) or SilentlyContinue, you may find this breaks your automation.

Example

 

Hopefully this is addressed in a future version of the Microsoft.Graph.Authentication module.

 

Cheers,

Lain

4 Replies

  • Have you tried the Try-Catch method?

    For example:

    try { Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/users/email address removed for privacy reasons" ` -Method GET ` -ErrorAction SilentlyContinue Write-Host "Request continued" } catch { Write-Host "Caught exception: $_" }

     

    • LainRobertson's avatar
      LainRobertson
      Silver Contributor

      Hi hasanemresatilmis​,

       

      Yes, I mentioned that in the original post.

       

      This wasn't a question from me but an FYI for the community's benefit.

       

      Cheers,

      Lain

    • LainRobertson's avatar
      LainRobertson
      Silver Contributor

      Hi Schnittlauch​,

       

      That's okay. I was only posting it for the community's benefit rather than for Microsoft's benefit.

       

      Cheers,

      Lain

Resources