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


Deletes specified database master key.


dbatools - Remove-DbaMasterKey


The master key in the master database on server1 will be removed if it exists.

Remove-DbaDatabaseMasterKey -SqlInstance Server1

Suppresses all prompts to remove the master key in the ‘db1’ database and drops the key.

Remove-DbaDatabaseMasterKey -SqlInstance Server1 -Database db1 -Confirm:$false


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


From PowerShell, execute Get-Help Remove-DbaDatabaseMasterKey -Detailed for more information on this function.

Source Code

Want to see the source code? View Remove-DbaDatabaseMasterKey.ps1 on GitHub

Related commands