Skip to content

Test‑SqlDscBackupFile

dscbot edited this page Dec 26, 2025 · 1 revision

SYNOPSIS

Verifies the integrity of a SQL Server backup file.

SYNTAX

Test-SqlDscBackupFile [-ServerObject] <Server> [-BackupFile] <String> [[-FileNumber] <Int32>] [-LoadHistory]
 [<CommonParameters>]

DESCRIPTION

This command verifies the integrity of a SQL Server backup file using SQL Server Management Objects (SMO). It uses the Restore.SqlVerify() method to check that the backup file is readable and that all data can be successfully read.

EXAMPLES

EXAMPLE 1

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Test-SqlDscBackupFile -BackupFile 'C:\Backups\MyDatabase.bak'

Verifies the integrity of the specified backup file and returns $true if the backup is valid, or $false if it is not.

EXAMPLE 2

$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$serverObject | Test-SqlDscBackupFile -BackupFile 'C:\Backups\MyDatabase.bak' -LoadHistory

Verifies the integrity of the specified backup file and loads the backup history during verification.

PARAMETERS

-BackupFile

Specifies the full path to the backup file to verify.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-FileNumber

Specifies the backup set number to verify when the backup file contains multiple backup sets. If not specified, the first backup set is verified.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-LoadHistory

Specifies whether to load the backup history during verification.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ServerObject

Specifies the current server connection object.

Type: Server
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

Microsoft.SqlServer.Management.Smo.Server

Server object accepted from the pipeline.

OUTPUTS

System.Boolean

Returns $true if the backup file is valid, $false otherwise. Use

-Verbose to see detailed error messages when verification fails.

NOTES

RELATED LINKS

Home

Commands

Resources

Usage

Clone this wiki locally