DCToolbox icon indicating copy to clipboard operation
DCToolbox copied to clipboard

Invoke-RestMethod : The remote server returned an error: (403) Forbidden.

Open cyberseckl opened this issue 2 years ago • 2 comments

I get the following error when I try to run New-DCConditionalAccessPolicyDesignReport I used a User with Global Admin rights, but it still gives me an Error 403. Is this a permission issue? What should I change?

Invoke-RestMethod : The remote server returned an error: (403) Forbidden. At C:\Program Files\WindowsPowerShell\Modules\DCToolbox\2.0.2\DCToolbox.psm1:1031 char:29

  • ... ryRequest = Invoke-RestMethod -Headers $HeaderParams -Uri $GraphUri - ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExcept ion
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

cyberseckl avatar Sep 07 '23 14:09 cyberseckl

I am running into the same issue using New-DCConditionalAccessPolicyDesignReport, DCToolbox 2.0.2 from PowerShellGallery.

If I try using PoSh 7.3.2 I get a different error..

VERBOSE: Generating Conditional Access policy design report... Invoke-RestMethod: {"error":{"code":"ResourceNotFound","message":"NamedLocation with id xxxxx does not exist in the directory.","innerError":{"date":"2023-09-14T22:25:51","request-id":"xxxxx","client-request-id":"xxxxx"}}}

c3rberus avatar Sep 14 '23 22:09 c3rberus

Looks like one of my CA policies had a stale location exclude, once I updated the CA policy and re-run DCConditionalAccessPolicyDesignReport it worked without issues.

c3rberus avatar Sep 14 '23 22:09 c3rberus