I have a PowerShell script that can be started either by
- running a shortcut on the desktop, OR
- as a scheduled job from the windows Task Scheduler.
Is there any way within the script itself of identifying how it was started? In practice each method produces a slowly scrolling command window on screen, and once it's running I have no way of knowing how it was initiated. The script already logs some data about itself (name, date, time and $PID) but so far I've not found how to test the launch method i.e. task scheduler or manual run.