I have a script to unzip files that I'm testing as a shutdown script. I have the property to visibly display script output set to true as well so I can see if it's being run. The script doesn't execute properly when it's used as a shutdown script.
The script runs as expected from the command line. Also runs correctly when testing the script using psexec to run as SYSTEM.
Here's the script. The output follows the script. All the output lines display properly. The script also sleeps at the end as expected. However, the zip file does NOT get extracted. The script goes right through that line and doesn't even throw an exception. Again, this script runs perfectly from the command line.
I'm stumped as to why all the rest of the script works, but the unzip part doesn't.
Here's one suggestion for finding hard-to-find errors like this: at the top of your script, invoke the following: $Error.Clear() Then, later in your script, after you think the zip extraction is complete, check if $Error contains anything and try to write it to disk so that you can see what non-terminating errors occurred when you run it as a shutdown script.