I’ve got a few sites where I’ve got PowerShell scripts scheduled to run on a regular basis. These have all been new things I’ve setup in the last week. Imagine my surprise when I find that the scripts are “still running” despite the fact they have done their job. It turns out that the commands you use to run a PowerShell script automatically can leave the PowerShell instance running after the script is complete. That in turn might well cause it to NOT run in following times. The end result is that I’ve been a little sneaky. I decided that given my script had finished, to make the last line of the script one that will kill the PowerShell instance.
Added this as the last line in the script and it works fine so far.
Leave a Reply