Error while connecting to MSOLService, Teams and IPPSsession using basic auth

Ananda Gedela 1 Reputation point
2023-08-08T06:00:28.6066667+00:00

While connecting to the MSOL service, Teams and IPPSSession using the powershell with Basic Auth(MFA disabled and necessry roles added), facing the below issue

Commands Ran:

$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username, $(convertto-securestring $password -asplaintext -force)
Connect-IPPSSession -Credential $cred
Connect-MsolService -Credential $cred

"errorMessage":"An error occurred while sending the request.","errorStackTrace":" at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Identity.Core.Http.HttpManager.<ExecuteAsync>d__9.MoveNext() in D:\\a\\1\\s\\src\\Microsoft.IdentityModel.Clients.ActiveDirectory\\Core\\Http\\HttpManager.cs:line 235\r\n--- End of stack trace from previous location "

Can anybody please help us in resolving this issue

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,894 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,922 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,332 questions
{count} votes

2 answers

Sort by: Most helpful
  1. NAZIFI ADAM 1 Reputation point
    2023-08-08T06:14:23.27+00:00

    these often occurs due to issues with the authentication process or network connectivity.


  2. Brian Zarb 1,670 Reputation points
    2023-08-08T06:25:40.9566667+00:00

    Instead Install the Azure module (install-module) and use the Connect-AzureAD to connect, here is how i typically do it:

    $securepass = ConvertTo-SecureString "Plainpassword" -AsPlainText -Force
    Connect-AzureAD -Credential (new-object system.management.automation.PScredential("******@email.com",$securepass)) -showbanner:$false
    
    

    This has worked several time for me , hopefully it does for you to.

    If you find this helpful, consider leaving a thumbs up and mark as your answer.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.