We have created a custom database Preview in Sitecore Sxa. We need to check this database is exist or not through Sitecore Powershell script.

Could someone let me know how we can check database exist or not in Sitecore powershell script?

1 Answer 1


Try out the below script, Just replace master with your database name.

if(($db = Get-Database -Name "master" -ErrorAction SilentlyContinue)) {
} else {
    Write-Host "Does not exist."

Hope it helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.