dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Creates a new credential.


dbatools - New-DbaCredential


You will be prompted to securely enter your password, then a credential will be created in the master database on server1 if it does not exist.

New-DbaCredential -SqlInstance Server1

Suppresses all prompts to install but prompts to securely enter your password and creates a credential in the ‘db1’ database

New-DbaCredential -SqlInstance Server1 -Database db1 -Confirm:$false


This command was created by Chrissy LeMaire. You can find Chrissy on Twitter.


From PowerShell, execute Get-Help New-DbaCredential -Detailed for more information on this function.

Source Code

Want to see the source code? View New-DbaCredential.ps1 on GitHub

Related commands