Author | Stuart Moore (@napalmgram), stuart-moore.com |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Get-DbaDbFile on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaDbFile.
Returns detailed information about database files.
Returns detailed information about database files. Does not use SMO - SMO causes enumeration and this command avoids that.
Get-DbaDbFile
[[-SqlInstance] <DbaInstanceParameter[]>]
[[-SqlCredential] <PSCredential>]
[[-Database] <Object[]>]
[[-ExcludeDatabase] <Object[]>]
[[-FileGroup] <Object[]>]
[[-InputObject] <Database[]>]
[-EnableException]
[<CommonParameters>]
PS C:\> Get-DbaDbFile -SqlInstance sql2016
Will return an object containing all file groups and their contained files for every database on the sql2016 SQL Server instance
PS C:\> Get-DbaDbFile -SqlInstance sql2016 -Database Impromptu
Will return an object containing all file groups and their contained files for the Impromptu Database on the sql2016 SQL Server instance
PS C:\> Get-DbaDbFile -SqlInstance sql2016 -Database Impromptu, Trading
Will return an object containing all file groups and their contained files for the Impromptu and Trading databases on the sql2016 SQL Server instance
PS C:\> Get-DbaDatabase -SqlInstance sql2016 -Database Impromptu, Trading | Get-DbaDbFile
Will accept piped input from Get-DbaDatabase and return an object containing all file groups and their contained files for the Impromptu and Trading databases on the sql2016 SQL Server instance
PS C:\> Get-DbaDbFile -SqlInstance sql2016 -Database AdventureWorks2017 -FileGroup Index
Return any files that are in the Index filegroup of the AdventureWorks2017 database.
The target SQL Server instance or instances
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The database(s) to exclude - this list is auto-populated from the server
Alias | |
Required | False |
Pipeline | false |
Default Value |
Filter results to only files within this certain filegroup.
Alias | |
Required | False |
Pipeline | false |
Default Value |
A piped collection of database objects
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |