Add-PnPStoredCredential

Adds a credential to the Windows Credential Manager

Syntax

Add-PnPStoredCredential
   -Name <String>
                          -Username <String>
                          [-Password <SecureString>]

Description

Adds an entry to the Windows Credential Manager. If you add an entry in the form of the URL of your tenant/server PnP PowerShell will check if that entry is available when you connect using Connect-PnPOnline. If it finds a matching URL it will use the associated credentials.

If you add a Credential with a name of "https://yourtenant.sharepoint.com" it will find a match when you connect to "https://yourtenant.sharepoint.com" but also when you connect to "https://yourtenant.sharepoint.com/sites/demo1". Of course you can specify more granular entries, allow you to automatically provide credentials for different URLs.

Examples

------------------EXAMPLE 1------------------

Add-PnPStoredCredential -Name https://tenant.sharepoint.com -Username yourname@tenant.onmicrosoft.com

You will be prompted to specify the password and a new entry will be added with the specified values

------------------EXAMPLE 2------------------

Add-PnPStoredCredential -Name https://tenant.sharepoint.com -Username yourname@tenant.onmicrosoft.com -Password (ConvertTo-SecureString -String "YourPassword" -AsPlainText -Force)

A new entry will be added with the specified values

------------------EXAMPLE 3------------------

Add-PnPStoredCredential -Name https://tenant.sharepoint.com -Username yourname@tenant.onmicrosoft.com -Password (ConvertTo-SecureString -String "YourPassword" -AsPlainText -Force)
Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/mydemosite

A new entry will be added with the specified values, and a subsequent connection to a sitecollection starting with the entry name will be made. Notice that no password prompt will occur.

Parameters

-Name

The credential to set

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Password

If not specified you will be prompted to enter your password. If you want to specify this value use ConvertTo-SecureString -String 'YourPassword' -AsPlainText -Force

Type:SecureString
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Username
Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False