dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Restore-DbaDatabase\Test-DbaBackupInformation - EnableException doesn't change warning to error if the files are already owned by another database on the instance

Open jpomfret opened this issue 1 year ago • 0 comments

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

I got this warning - even when specifying -EnableException it doesn't change to throw an error and therefore can't be trapped

image

Steps to Reproduce

Need to already have a pubs database existing and then try and restore a second with a new name


$restoreParams = @{
    SqlInstance = $primary
    DatabaseName = ('{0}_jp' -f $psitem)
    Path = ('{0}/{1}' -f $backupPath, $db)
    RestoreTime = $restoreToTime
    WithReplace = $true
    EnableException = $true
}
Restore-DbaDatabase @restoreParams -verbose

Please confirm that you are running the most recent version of dbatools

2.1.5

Other details or mentions

No response

What PowerShell host was used when producing this error

VS Code (terminal), VS Code (integrated terminal)

PowerShell Host Version

Name                           Value
----                           -----
PSVersion                      7.3.11
PSEdition                      Core
GitCommitId                    7.3.11
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

SQL Server Edition and Build number

Microsoft SQL Server 2019 (RTM-CU18) (KB5017593) - 15.0.4261.1 (X64) Sep 12 2022 15:07:06 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 20.04.5 LTS) <X64>

.NET Framework Version

.NET 7.0.15

jpomfret avatar Feb 14 '24 15:02 jpomfret