Reputation: 43
Im using powershell to connect to azure ad and what I need is to get a list of the policies that were configured.
First, I used Connect-azuread
to get into my tenant, and when I tryed to use Get-AzureADPolicy
, I'm having this error:
Get-AzureADPolicy: Error occurred while executing GetPolicies Code: InvalidAuthenticationToken Message: Access token validation failure. Invalid audience. InnerError: DateTimeStamp: Wed, 16 Feb 2022 20:36:13 GMT HttpStatusCode: Unauthorized HttpStatusDescription: Unauthorized HttpResponseStatus: Completed
any ideas of what could I been doing wrong?
Thanks
Upvotes: 0
Views: 791
Reputation: 22542
I have tested in my environment. I was able to get the list of policies successfully.
Try using AzureADPreview
latest module
Uninstall-Module AzureAD
Install-Module AzureADPreview
Import-Module AzureADPreview
Now, use cmdlet “Connect-AzureAD
” with credentials and “Get-AzureADPolicy
” to display the list of policies.
If still the error remains, please check if you have permissions and granted consent for the same.
Try with "Connect-AzureAD -AzureEnvironmentName AzureUSGovernment"
Reference:
Get-AzureADDirectorySetting - Authintication problems - Microsoft Q&A
Upvotes: 1