Context:
I need to be able to catch warnings that are preventing some backups from being restored when using the Restore-DbaDatabase cmdlet.
I found some posts mentioning that the -Silent parameter for the Restore-DbaDatabase would treat those warnings as errors so I could catch them, but this parameter no longer exists.
I'm using the -EnableException parameter with no luck. Warnings are shown on screen, but I'm unable to catch them in my scripts since no Exception is thrown, as show in the following image:
Question:
What is the right approach to catch/capture all the warnings for a dbatools command?
A little rough, however, here is what I do: