Skip to content

Commit 5d74f6c

Browse files
committed
Update Restore-SqlDscDatabase to enforce NoRecovery in Standby mode
1 parent 5f8e04b commit 5d74f6c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

source/Public/Restore-SqlDscDatabase.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,17 +446,18 @@ function Restore-SqlDscDatabase
446446
{
447447
$restore.NoRecovery = $true
448448
}
449+
elseif ($PSBoundParameters.ContainsKey('Standby'))
450+
{
451+
# When using Standby mode, NoRecovery must be set to true
452+
$restore.NoRecovery = $true
453+
$restore.StandbyFile = $Standby
454+
}
449455
else
450456
{
451457
# Explicitly set NoRecovery to false to ensure the database is brought online
452458
$restore.NoRecovery = $false
453459
}
454460

455-
if ($PSBoundParameters.ContainsKey('Standby'))
456-
{
457-
$restore.StandbyFile = $Standby
458-
}
459-
460461
if ($ReplaceDatabase.IsPresent)
461462
{
462463
$restore.ReplaceDatabase = $true

0 commit comments

Comments
 (0)