Avoid SharePoint Login from PowerShell

A PowerShell with SharePoint tutorial

PowerShell iconTo avoid having to log in to SharePoint every time you want to run a PowerShell script, you can save the credentials. In the demo below, Peter Kalmström shows two ways to do that.

The Browser Login

If you have saved your login credentials in the browser, you can let PowerShell fetch them with the command "-UseWebLogin" after the URL (or the variable that contains the URL).

$URL = "PATH"
Connect-PnPOnline $URL -UseWebLogin

Windows Credential Manager

When you are working with multiple sites, you should spend some time on saving your login credentials in the Windows Credential Manager. This method is also the most secure one, as it saves the password in a secure string.

Peter first creates a variable that stores the credentials, and then he adds this stored credential variable to Windows Credential Manager.
PowerShell with SharePoint from Scratch cover
Add-PnPStoredCredential -Name $URL -Username $Creds.UserName -Password $Creds.Password


You will find more detailed explanations in the book.



 Download the scripts Peter creates in the demo:

Web Browser

Windows Credential Manager

In the next article, we will see how apps can be created and removed with PowerShell code. Later we will expand this code to give a possibility to create multiple apps with different names in just one script run.



back icon next icon
Products Buy FAQ Services Tips Books Contact About Us Tools

Security and integrity

Copyright  Kalmstrom Enterprises AB  All rights reserved