Powershell for SQL

Where are my system databases?

Hi Friends,

In last post, we saw that we can very easily use powershell to connect to SQL Server instance and see all the available databases (http://www.sarabpreet.com/?p=288), but by default powershell maintains security and hide all system level databases. Now the question arises how to list\view system databases in powershell.

Well to do this, all you have to do is use an extra switch called FORCE, this forces powershell to show all content.

let’s see how to use this.

If we use the  normal get-childitem cmdlet it will just display the user databases like the below screenshot.

default behaviour

Now let’s use the force switch, Like: get-childitem –force, this will change the default behavior and show all Databases including System Databases.

with force switch

Enjoy!

Happy Learning.

Thanks,
Sarabpreet Singh

One thought on “Where are my system databases?

Comments are closed.