msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Invoke-MgGraphRequest -ErrorAction Ignore
Describe the bug
The argument -ErrorAction Ignore is not respected by Invoke-MgGraphRequest.
To Reproduce
The code below ends up in the Catch clause, which shouldn't be happening.
try {
$params = @{
Uri = "v1.0/drives/{0}/items/{1}" -f $drive.Id, $notExistingFileId
Method = 'DELETE'
}
Invoke-MgGraphRequest @params -ErrorAction Ignore
}
catch {
throw "Oops: $_"
}
Expected behavior No error
Debug Output
Exception: T:\Brecht\PowerShell\Testie7.ps1:41:5
Line |
41 | throw "Oops: $_"
| ~~~~~~~~~~~~~~~~
| Oops: DELETE https://graph.microsoft.com/v1.0/drives/b!dsd-p_J-ssd/items/sdd HTTP/2.0 404 Not Found Cache-Control: no-store,
| no-cache Vary: Accept-Encoding Strict-Transport-Security: max-age=31536000 request-id: 9f3f0c0c-dea4-4fcc-b90e-cc7a7bd98497 client-request-id: 42fbac5b-3f74- x-ms-ags-diagnostic:
| {"ServerInfo":{"DataCenter":"West Europe","Slice":"E","Ring":"5","ScaleUnit":"010","RoleInstance":"AM4PEPF0002BAE7"}} Date: Mon, 25 Mar 2024 15:08:49 GMT Content-Type: application/json Content-Encoding: gzip
| {"error":{"code":"itemNotFound","message":"The resource could not be
| found.","innerError":{"date":"2024-03-25T15:08:50","request-id":"9f3f0c0c-dea4-4fcc-497","client-request-id":"42fbac5b-3f7"}}}
Module Version Script 2.15.0 Microsoft.Graph.Sites
Environment Data Name Value
PSVersion 7.4.1 PSEdition Core GitCommitId 7.4.1 OS Microsoft Windows 10.0.20348 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0