This post was most recently updated on March 28th, 2023.2 min read.
This post describes a simple way to get around the following error while running Connect-PnPOnline: “The sign-in name or password does not match one in the Microsoft account system.” Truthfully, this one is kind of simple and stupid – but as I’ve seen before, it’s surely worth documenting anyway!
Below is an example of such an error.
PS C:\> Connect-PnPOnline https://contoso.sharepoint.com/sites/CommunicationSite/ Connect-PnPOnline : The sign-in name or password does not match one in the Microsoft account system. At line:1 char:1 + Connect-PnPOnline https://contoso.sharepoint.com/sites/CommunicationS ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], IdcrlException + FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline
In my case, I had saved my credentials in a password manager, yet in a script, I was developing I ran into this error time and time again. I didn’t remember encountering it before, so my natural first guess was that the password had expired.
However, I could log in with the account, so the password and username I was using were correct. Then what causes this?
Are you sure you have entered your username and password correctly? You are? Good.
Have you disabled the credential caching (see below)? Great.
If you’ve avoided all the abovementioned pitfalls, you might’ve run into the same issue I did, and feel as stupid as me after reading the next sentence.
Quotes. You need quotes around the URL, even if it doesn’t contain a space. This issue might manifest if you are pasting values in the PowerShell – which is exactly what I did.
Without the quotes, the cmdlet returns this error. While the error might not be the most informative at first sight, it actually makes sense: since the cmdlet is not able to figure out where it’s trying to login with your credentials – technically, your sign-in name and password do not match the ones Microsoft supposedly has for whatever null tenant they’re trying to authenticate you against.
So, make sure to try and authenticate against an URL that makes sense. One, that has quotes around it :)
Another thing to verify, as Faisal points out in the comments -section below, is that you’re using -UseWebLogin switches if your user account has MFA turned on. Worth trying out in any case :)
- How to find out dependency versions in your .csproj files using PowerShell? - September 26, 2023
- node build throwing “error:0308010C:digital envelope routines::unsupported”? Let’s fix it! - September 19, 2023
- “This app can’t run on your PC” dialog when you’re building your app in Visual Studio - September 12, 2023