In this recipe, we will see how to list backup header information from a backup file.
We need to list the existing backup's header information.
To list the header information, follow these steps:
Open PowerShell ISE as administrator.
Import the
SQLPS
module as follows:#import SQL Server module Import-Module SQLPS -DisableNameChecking
Add the following script and run:
$instanceName = "localhost" $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName #replace this with your backup file $backupfile = "AdventureWorks2014.bak" #replace this with your backup directory $backupdir = $server.Settings.BackupDirectory #get full path $backupfilepath = Join-Path $backupdir $backupfile #SMO restore object will allow us to #investigate contents...