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 service master key in the master database.


dbatools-New - DbaServiceMasterKey


You will be prompted to securely enter your Service Key Password twice, then a master key will be created in the master database on server1 if it does not exist.

New-DbaServiceMasterKey -SqlInstance Server1


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


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

Source Code

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

Related commands