commands

^

Get-DbaDbDetachedFileInfo

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Synopsis

Get detailed information about detached SQL Server database files.

Description

Gathers the following information from detached database files: database name, SQL Server version (compatibility level), collation, and file structure.

"Data files" and "Log file" report the structure of the data and log files as they were when the database was detached. "Database version" is the compatibility level.

MDF files are most easily read by using a SQL Server to interpret them. Because of this, you must specify a SQL Server and the path must be relative to the SQL Server.

Syntax

Get-DbaDbDetachedFileInfo
    [-SqlInstance] <DbaInstanceParameter>
    [[-SqlCredential] <PSCredential>]
    [-Path] <String[]>
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaDbDetachedFileInfo -SqlInstance sql2016 -Path M:\Archive\mydb.mdf

Returns information about the detached database file M:\Archive\mydb.mdf using the SQL Server instance sql2016. The M drive is relative to the SQL Server instance.

Required Parameters

-SqlInstance

Source SQL Server. This instance must be online and is required to parse the information contained with in the detached database file. This function will not attach the database file, it will only use SQL Server to read its contents.

Alias
Required True
Pipeline false
Default Value
-Path

Specifies the path to the MDF file to be read. This path must be readable by the SQL Server service account. Ideally, the MDF will be located on the SQL Server itself, or on a network share to which the SQL Server service account has access.

Alias Mdf,FilePath,FullName
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-SqlCredential

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
-EnableException

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

 

Want to see the source code for this command? Check out Get-DbaDbDetachedFileInfo on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaDbDetachedFileInfo.