I have a Powershell script to copy our production database to our test environment as well as associated clean up activities. I'd like to clean up the information outputted for the user to the console, and am having trouble figuring out clean up the error messages I get from my Az.sql commands.
One of my first actions is to attempt to see if a temporary database exists for and needs to be cleaned up
#clean up existing
$availableDatabase = Get-AzSqlDatabase -ResourceGroupName $TestResourceGroup -ServerName $TestServerName -DatabaseName $TestTempDatabaseName
If it's not there I'll get the following error output in the console:
Remove-AzSqlDatabase : The Resource
'Microsoft.Sql/servers/xxxx/databases/reap_prod_copy_2' under resource group 'xxxx' was not found.
At C:\Users\xxxx\Desktop\reap-replace-test.ps1:17 char:1
+ Remove-AzSqlDatabase -ResourceGroupName $TestResourceGroup -ServerNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Remove-AzSqlDatabase], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.Database.Cmdlet.RemoveAzureSqlDatabase
I would like to capture this output and provide a simple "Does not exist" message instead, or even just completely move on without any output. I've tried putting "| Out-Null" on the end, but that doesn't seem to effect the output in any way. Any insights?

