title: PowerBI Invoke-PowerBIRestMethod Extract Exception Trace
body: <p>While invoking PowerBI Rest APIs using the Invoke-PowerBIRestMethod exception trace is getting abstracted, tried accessing it through $_.Exception.Message still it doesn't print the actual exception message/trace, has little experience in Powershell it should be straight forward to extract the exception message.</p>
  <pre><code>try{
   Invoke-PowerBIRestMethod -Url &quot;url....&quot;
  }catch {
   Write-Host $_.Exception.Message -Foreground &quot;Red&quot;
   Write-Host $_.ScriptStackTrace -Foreground &quot;DarkGray&quot;
   throw &quot;Exception During PowerBI CmdLets!!&quot;
  }
  </code></pre>
  <p>Exception:</p>
  <pre><code>Invoke-PowerBIRestMethod : One or more errors occurred.
  At D:\a\r1\a\lib\scripts\updateparameters.ps1:53 char:2
  +  Invoke-PowerBIRestMethod -Url &quot;groups/$($workspace.id)/datasets/$($d ...
  +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) 
  [Invoke-PowerBIRestMethod], AggregateException
  + FullyQualifiedErrorId : One or more errors 
  occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
  </code></pre>