I need help and a solution to rectify the below error when executing the PowerShell Connect-* command.
$TenantID = '22bb9241-65c8-45b4-94f9-7c151e154693'
$AzSubscriptionID = 'd487514e-4317-447f-af79-5022d310f6bd'
$paramConnectMgGraph = @{
Scopes = 'User.ReadWrite.All', 'Group.ReadWrite.All', 'Directory.ReadWrite.All', 'UserAuthenticationMethod.Read.All'$RequiredScopes
TenantId = $TenantID
NoWelcome = $true
}
Update-AzConfig -DefaultSubscriptionForLogin $AzSubscriptionID
Connect-AzAccount -Tenant $TenantID -Verbose
Connect-MgGraph @paramConnectMgGraph
Get-Module *Az *Graph*
$PSVersionTable | ft -AutoSize
The script consistently throws errors, even though it is executed as a Local Administrator with the appropriate permissions granted.
Connect-AzAccount : InteractiveBrowserCredential authentication failed: A window handle must be configured. See https://aka.ms/msal-net-wam#parent-window-handles
Could not find the tenant ID for the provided tenant domain '22bb9241-65c8-45b4-94f9-7c151e154693'. Please ensure that the provided user is found in the provided tenant domain.
At line:17 char:1
+ Connect-AzAccount -Tenant $TenantID -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Connect-AzAccount], ArgumentNullException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
Connect-MgGraph : Invalid JWT access token.
At line:18 char:1
+ Connect-MgGraph @paramConnectMgGraph
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-MgGraph], AuthenticationException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 3.0.0 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}
Binary 2.0.2.182 AzureAD {Add-AzureADApplicationOwner, Add-AzureADDeviceRegisteredOwner, Add-AzureADDeviceRegisteredUser, Add-AzureADDirectoryRoleMember...}
Script 2.19.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext...}
Name Value
---- -----
PSVersion 5.1.20348.2400
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.20348.2400
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Any help would be greatly appreciated.