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




To use Windows auth

Get-DbaDetachedDatabaseInfo -SqlServer sqlserver -MDF M:\Archive\mydb.mdf

To use SQL auth

Get-DbaDetachedDatabaseInfo -SqlServer sqlserver -SqlCredential $SqlCredential -MDF M:\Archive\mydb.mdf


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

Source Code

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

Related commands