Forum Discussion
kcelmer
Dec 15, 2025Brass Contributor
Error trying to Connect-PnPOnline
Hi! I'm using PowerShell in VSC to run the following script: # Install PnP PowerShell module if not already installed
# Install-Module PnP.PowerShell -Force
# Define SharePoint site URL, folder p...
devjelly
Dec 22, 2025MCT
Hi kcelmer, is this issue resolved or still persists?
In case you are still facing this issue, here is my take. It looks like PowerShell can’t load the msalruntime DLL that modern authentication needs, so Connect-PnPOnline -UseWebLogin is failing in your PowerShell 7 + VS Code environment.
A couple of simple options you can try:
- Run the same script from Windows PowerShell 5.1 (with PnP.PowerShell installed), where this usually works fine.
- Instead of -UseWebLogin, create an Entra ID app registration and use app-only authentication (certificate or client secret) with Connect-PnPOnline, which avoids the WAM/MSAL interactive dependency completely.
- kcelmerDec 22, 2025Brass Contributor
Thank you DevJelly!
I did eventually create an Entra ID app and it works. It had never done that before, so I was reluctant, but it turned out to be pretty easy.
Thanks!