Avoid SharePoint Login from PowerShell
A PowerShell with SharePoint tutorial
To
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.
Add-PnPStoredCredential -Name $URL -Username $Creds.UserName -Password $Creds.Password
You will find more detailed explanations in
the
book.
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.
|