< Back

Get-DbaDbDetachedFileInfo

Mon Jan 13, 2020 10:39 am

NAME Get-DbaDbDetachedFileInfo



SYNOPSIS

Get detailed information about detached SQL Server database files.





SYNTAX

Get-DbaDbDetachedFileInfo [-SqlInstance] <DbaInstanceParameter> [[-SqlCredential] <Pscredential>] [-Path]

<System.String[]> [-EnableException <Switch>] [<CommonParameters>]





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.





PARAMETERS

-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Path [<System.String[]>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<DbaInstanceParameter>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Database, Detach

Author: Chrissy LeMaire (@cl), netnerds.net



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



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



RELATED LINKS

https://dbatools.io/Get-DbaDbDetachedFileInfo