Invoke-RestMethod : The remote server returned an error: (403) Forbidden.
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
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"}}}
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.