I need to test some archives in a Powerhsell script as I am automating the compression of a bunch of backup files with 7z
.
Now I know that normally when a program runs it returns 0 if everything completed normally; but will return some other value if it did not complete normally.
For example we see here in Scheduled Tasks
that the Last Result displays 0x0
when the task completes successfully, and other values if it did not.
When I use Invoke-Expression
in Powershell to run 7z
to test the archive, I need to be able to pull the program return value to make sure that the archive tested successfully; is there any way to get this value from Invoke-Expression
?
I'm calling the following command from Invoke-Expression:
7z t C:\backups\somezip.7z *.* -r
Also what is the value I'm talking about called? I know that if you write a program in C++ you return the value from the main
method, but I'm not certain what it is called.