PowerBI Invoke-PowerBIRestMethod Extract Exception Trace

Viewed 1642

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.

try{
 Invoke-PowerBIRestMethod -Url "url...."
}catch {
 Write-Host $_.Exception.Message -Foreground "Red"
 Write-Host $_.ScriptStackTrace -Foreground "DarkGray"
 throw "Exception During PowerBI CmdLets!!"
}

Exception:

Invoke-PowerBIRestMethod : One or more errors occurred.
At D:\a\r1\a\lib\scripts\updateparameters.ps1:53 char:2
+  Invoke-PowerBIRestMethod -Url "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
0 Answers
Related