I hadn’t noticed this before.

If you do a dir listing of the databases for an instance within the Powershell Sqlserver provider, it doesn’t show the system databases

PS C:powershell> dir SQLSERVER:\SQL\my_pcinst2012\databases

Name                 Status          Recovery Model CompatLvl Collation                      Owner
----                 ------          -------------- --------- ---------                      -----
AdventureWorks2012   Normal          Simple               110 SQL_Latin1_General_CP1_CI_AS   matty
TSQL2012             Normal          Full                 110 Latin1_General_CI_AS           matty

To get a listing for the system databases you can do the following. I would imagine there’s a better way (perhaps some equivalent to ls -a?)…but I can’t think of it at the minute1

PS C:powershell> foreach ($DB in ("master", "msdb", "model", "tempdb")) {gi SQLSERVER:\SQL\my_pcinst2012\databases\$DB }

Name                 Status          Recovery Model CompatLvl Collation                      Owner
----                 ------          -------------- --------- ---------                      -----
master               Normal          Simple               110 Latin1_General_CI_AS           sa
msdb                 Normal          Simple               110 Latin1_General_CI_AS           sa
model                Normal          Simple               110 Latin1_General_CI_AS           sa
tempdb               Normal          Simple               110 Latin1_General_CI_AS           sa

  1. The ‘better way’ is to use gci -force. That includes all the system databases. ↩︎