dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


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.

Screenshots

get-detacheddbinfo

Examples

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

Get-Help

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