Listing backup header and FileList information
In this recipe, we will see how to list backup header information from a backup file.
Getting ready
We need to list the existing backup's header information.
Note
If you do not have any backups in your system yet, you can go back to any of this chapter's Backup recipes prior to performing this recipe.
How to do it...
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...