title: Powershell test for noninteractive mode
body: <p>I have a script that may be run manually or may be run by a scheduled task. I need to programmatically determine if I'm running in -noninteractive mode (which is set when run via scheduled task) or normal mode. I've googled around and the best I can find is to add a command line parameter, but I don't have any feasible way of doing that with the scheduled tasks nor can I reasonably expect the users to add the parameter when they run it manually.
  Does noninteractive mode set some kind of variable or something I could check for in my script?</p>
  
  <p>Edit:
  I actually inadvertently answered my own question but I'm leaving it here for posterity.</p>
  
  <p>I stuck a read-host in the script to ask the user for something and when it ran in noninteractive mode, boom, terminating error. Stuck it in a try/catch block and do stuff based on what mode I'm in.</p>
  
  <p>Not the prettiest code structure, but it works. If anyone else has a better way please add it! </p>