You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously we were using Credentials to fetch DSC components, as the -AccessTokens is introduced I am trying to fetch DSC components with it, but it doesn't work.
Error:- {NotSpecified} Microsoft.Graph.PowerShell.AuthenticationException: Authentication needed. Please call Connect-MgGraph. at Microsoft.Graph.PowerShell.Authentication.Core.Utilities.AuthenticationHelpers.<GetAuthenticationProviderAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient() at Microsoft.Graph.Beta.PowerShell.Module.BeforeCreatePipeline(InvocationInfo invocationInfo, HttpPipeline& pipeline) at Microsoft.Graph.Beta.PowerShell.Module.CreatePipeline(InvocationInfo invocationInfo, String parameterSetName) at Microsoft.Graph.Beta.PowerShell.Cmdlets.GetMgBetaPolicyAuthorizationPolicy_List.<ProcessRecordAsync>d__88.MoveNext() "Could not find existing authorization policy" at Get-MgBetaPolicyAuthorizationPolicy<Process>, C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Beta.Identity.SignIns\2.19.0\exports\ProxyCmdletDefinitions.ps1: line 32142 at Get-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.515.2\DSCResources\MSFT_AADAuthorizationPolicy\MSFT_AADAuthorizationPolicy.psm1: line 127 at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.515.2\DSCResources\MSFT_AADAuthorizationPolicy\MSFT_AADAuthorizationPolicy.psm1: line 585 at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.515.2\Modules\M365DSCReverse.psm1: line 677 at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.515.2\Modules\M365DSCUtil.psm1: line 1375 at <ScriptBlock>, <No file>: line 1 TenantId: xyz.onmicrosoft.com
How did I generate Access Token ?
I used Oauth2 flow with required scopes [Policy.Read.All Policy.ReadWrite.Authorization].
Now I am trying to fetch DSC component AADAuthorizationPolicy by executing the following command Export-M365DSCConfiguration -Components @("AADAuthorizationPolicy") -AccessTokens ['eyubdbsdjsdsjdj'] -TenantId "xyz.onmicrosoft.com"
And I am facing the error shared above, when I do Connect-MgGraph it pops up the browser screen I login with Global Administrator account, but still the above error persists.
Microsoft 365 DSC Version
1.24.515.2
Which workloads are affected
Azure Active Directory (Entra ID), Exchange Online, Office 365 Admin, OneDrive for Business, SharePoint Online, Teams
@99conqueror99 The authentication with AccessTokens should work by now. Please try again. I will close the issue, if it doesn't work, feel free to reopen it.
Description of the issue
Previously we were using Credentials to fetch DSC components, as the -AccessTokens is introduced I am trying to fetch DSC components with it, but it doesn't work.
DSC command:-
Export-M365DSCConfiguration -Components @("AADAuthorizationPolicy") -AccessTokens ['eyubdbsdjsdsjdj'] -TenantId "xyz.onmicrosoft.com"
Error:-
{NotSpecified} Microsoft.Graph.PowerShell.AuthenticationException: Authentication needed. Please call Connect-MgGraph. at Microsoft.Graph.PowerShell.Authentication.Core.Utilities.AuthenticationHelpers.<GetAuthenticationProviderAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient() at Microsoft.Graph.Beta.PowerShell.Module.BeforeCreatePipeline(InvocationInfo invocationInfo, HttpPipeline& pipeline) at Microsoft.Graph.Beta.PowerShell.Module.CreatePipeline(InvocationInfo invocationInfo, String parameterSetName) at Microsoft.Graph.Beta.PowerShell.Cmdlets.GetMgBetaPolicyAuthorizationPolicy_List.<ProcessRecordAsync>d__88.MoveNext() "Could not find existing authorization policy" at Get-MgBetaPolicyAuthorizationPolicy<Process>, C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Beta.Identity.SignIns\2.19.0\exports\ProxyCmdletDefinitions.ps1: line 32142 at Get-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.515.2\DSCResources\MSFT_AADAuthorizationPolicy\MSFT_AADAuthorizationPolicy.psm1: line 127 at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.515.2\DSCResources\MSFT_AADAuthorizationPolicy\MSFT_AADAuthorizationPolicy.psm1: line 585 at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.515.2\Modules\M365DSCReverse.psm1: line 677 at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.515.2\Modules\M365DSCUtil.psm1: line 1375 at <ScriptBlock>, <No file>: line 1 TenantId: xyz.onmicrosoft.com
How did I generate Access Token ?
API used to fetch Token:-
https://login.microsoftonline.com{TENANT_ID}/oauth2/v2.0/authorize?client_id={CLIENT_ID}&response_type=code&scope=Policy.Read.All Policy.ReadWrite.Authorization
Token -
https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token
Successfully Generated token
Now I am trying to fetch DSC component AADAuthorizationPolicy by executing the following command
Export-M365DSCConfiguration -Components @("AADAuthorizationPolicy") -AccessTokens ['eyubdbsdjsdsjdj'] -TenantId "xyz.onmicrosoft.com"
And I am facing the error shared above, when I do Connect-MgGraph it pops up the browser screen I login with Global Administrator account, but still the above error persists.
Microsoft 365 DSC Version
1.24.515.2
Which workloads are affected
Azure Active Directory (Entra ID), Exchange Online, Office 365 Admin, OneDrive for Business, SharePoint Online, Teams
The DSC configuration
Verbose logs showing the problem
Environment Information + PowerShell Version
The text was updated successfully, but these errors were encountered: