Quantcast
Channel: R&D Forums
Viewing all articles
Browse latest Browse all 9996

Veeam Backup & Replication • Re: SureBackup & Exit Codes

$
0
0
Hi David, thanks for the reply and info on this one. I tested appending the "; exit $LASTEXITCODE" to the end of the arguments line in the SB job setup and got some syntax errors, so I shifted over to trying to manipulate and set the $? automatic variable and I had some promising testing.

I did notice that we're still on PowerShell 5.1 in this environment which doesn't have the ability to directly set the $? variable, but I read that calling the Write-Error cmdlet outside of a function will set $? to false after it is executed (from https://learn.microsoft.com/en-us/power ... #section-1)

"The Write-Error cmdlet always sets $? to False immediately after it's executed, but won't set $? to False for a function calling it:"

After some trial and error and manual testing, I added this line to my if statement that checks for mismatched hashes and exits with 1 if they're mismatched, and this seems to force $? to false:

Code:

Write-Error "nope" | out-null
Manual testing and verification of the $? value all went as planned, I'm going to run the proper test in the morning and will report back with results.

As always David, thank you so much for your help and contributions on this board, have a great evening.

-Adam

Statistics: Posted by theadamlion — May 16, 2024 8:51 pm



Viewing all articles
Browse latest Browse all 9996

Latest Images

Trending Articles



Latest Images