See image. I am getting the error "Exception calling "ExecuteQuery" with "0" argument(s): "The sign-in name or password does not match one in the Microsoft account system." when I try to connect to SP Online using PowerShell and just grab some list items. I know my username and password are right. We use Azure and Local AD sync and it's correct. Do I need certain permissions to pull data down with Powershell API? can only super admins do it? I am confused. I have executed script in Sharepoint Online Management Shell and in Powershell ISV. No Luck.



2 Answers 2


The same issue is being raised and discussed in the Microsoft Technet community where a user reported, his same code worked in the test tenant but it is not working in another tenant. They have concluded this is the issue with ADFS authentication.

As for troubleshooting, you can try the below:

  • If ADFS authentication is configured then this can be one cause.
  • Make sure DNS is configured properly
  • used custom dll to authentication for ADFS (not sure if option is available with sharepoint online powershell)
  • If nothing works, raise a ticket to Microsoft.

Reference to the source thread:

Powershell script for SharePoint online inventory fails with FullyQualifiedErrorId : IdcrlException

Powershell command for SharePoint Online site+Exception calling "ExecuteQuery" with "0" argument(s):

As an alternate, you can use the below PnP command to authenticate:

 Connect-PnPOnline -Url $siteUrl –UseWebLogin

I am using the below code which is the same as your one, it is working for me without any issues.

$userName = "[email protected]"
$password = "YourPassWord"
$securePassword= $password | ConvertTo-SecureString -AsPlainText -Force 

#Setup the Context
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $securePassword)

#Get the List
$list = $ctx.Web.Lists.GetByTitle($listName)


  • Make sure you are not in a VPN connection.
  • If your account has MFA enabled, try do disable for time being and try that. However, as per the latest update from Microsoft we can connect to the SharePoint Online using PowerShell Management Shell with MFA enabled account.

For details refer to the below article :

SharePoint Online Automation – O365 – Download files from a document library using PowerShell CSOM


How to connect to SharePoint online using PnP without login prompt?

 $userName = "[email protected]" 

$passWord = "YourSPOOnlinePassword"

 $encPassWord = convertto-securestring -String $passWord -AsPlainText -Force $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName, $encPassWord 

  Connect-PnPOnline -Url "https://globalsharepoint2019-admin.sharepoint.com/" -Credentials $cred
  • I was able to get logged in using PnP, but it prompts me. So I will need to ask my IT director for an access token I believe to make my script automated and not require a prompt. docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/…
    – kyleb
    Commented Apr 29, 2020 at 18:56
  • Please refer to the updated answer, where you will not get prompt in PnP connect... reference URL :global-sharepoint.com/sharepoint-online/…
    – SP 2022
    Commented Apr 29, 2020 at 22:51
  • I think I need an admin account or account with higher privilege than I have to make that work. I did what you said in the update. I think it's better to maybe use an access token instead since it's an automated server job.
    – kyleb
    Commented May 1, 2020 at 1:13

Likely the issue is Modern Authentication [and] MFA, which prevents you from using just a username and password. You should move to the SharePoint Addin model using client ID and secrets.

Add-in permissions in SharePoint

  • Agree, in many tenants legacy Authentication is being disabled for security reason. Standard CSOM library does not support modern authentication. It also does not support MFA. Commented Apr 30, 2020 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.