dbatools is a free PowerShell module with over 200 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


Get-DbaDatabaseFile

Returns detailed information about database files. Does not use SMO – SMO causes enumeration and this command was created explicitly in order to avoid enumeration.

Screenshots

Examples

To return an object containing all filegroups and their contained files for every database on the sql2016 SQL Server instance

Get-DbaDatabaseFile -SqlInstance sql2016

To return an object containing all filegroups and their contained files for the Impromptu Database on the sql2016 SQL Server instance

Get-DbaDatabaseFile -SqlInstance sql2016 -Database Impromptu

To return an object containing all filegroups and their contained files for the Impromptu and Trading databases on the sql2016 SQL Server instance

Get-DbaDatabaseFile -SqlInstance sql2016 -Database Impromptu, Trading

Get-Help

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

Source Code

Want to see the source code? View Get-DbaDatabaseFile.ps1 on GitHub
 

Related commands