Restore-DbaDbSnapshot error handling #7399
-
Hello. For example, I use this command: it executes without any error or return result. How to handle the case when the database wasn't restored? I tried to add -EnableException but nothing changed. It seems, that I'm missing something quite obvious, but it isn't clear what exactly. PS |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Have a look at the source code. The command first runs this: |
Beta Was this translation helpful? Give feedback.
Have a look at the source code. The command first runs this:
Get-DbaDbSnapshot -SqlInstance $server -Database $Database -ExcludeDatabase $ExcludeDatabase -Snapshot $Snapshot
.With an incorrect snapshot name, the Get- command does not return anything. That is by design. If you want to make sure that there is a snapshot with that name, you have to use
Get-DbaDbSnapshot
yourself and test if there is a result.