

PnP PowerShell will then try to match the most complete label first, e.g. Notice that a URL like will also match the secret. PnP PowerShell will check the vault if a secret is present with the label matching the URL and it will use those credentials. Now you can simply do this: Connect-PnPOnline -Url "" Set-Secret -Name "" -Secret (Get-Credential) You can add a secret with a label that reflects your tenant url, e.g. PnP PowerShell Connect-PnPOnline -Url -Credentials Retrieving a secret Secret Management Module Connect-PnPOnline -Url -Credentials (Get-Secret -Name ) You will be prompted to provide a password. PnP PowerShell Add-PnPStoredCredential -Name -Username Adding a secret Secret Management Module Set-Secret -Name -Secret (Get-Credential) If you intend to use the native out of the box functionality of PnP PowerShell with the Secret Management modules, notice that the authentication is required to set to None. Notice that you will be asked several times to provide a password the moment you create a new vault.

The last cmdlet, where you set the authentication to None means that you will allow access to the secret store without requiring you to enter a password to unlock the vault.

Install-Module -Name ""Īfter installing the module, create and register a vault: Register-SecretVault -Name "SecretStore" -ModuleName "" -DefaultVault Install the required modules Install-Module -Name "" We currently recommend the Microsoft provided Secret Management and Secret Store modules to set up a vault which PnP PowerShell can use to store and retrieve credentials. You should -never- store them in your scripts.

However, in order to automate authentication you need to safely store these credentials. PnP PowerShell is the ultimate library to execute cmdlets unattended in scripts, Azure Functions or Azure Automation.
