title: How can I run a powershell script as a background task without displaying a window?
body: <p>I'm working on creating a script that will fire off performance counters and store them in a .csv file, rolling over when the file gets too big. Running the script from a powershell prompt or the ISE (I'm running v.2/win server 2008) works just fine, and the files are running correctly.</p>
  
  <p>However, when I try to execute the command using the following cmd prompt line (even trying the /k switch on cmd), the command prompt closes immediately and the file is not getting run.</p>
  
  <pre><code>powershell.exe -windowstyle hidden {iis_test.ps1}
  </code></pre>
  
  <p>I've also tried the following, and although I see Powershell doesn't stop (I monitor it via task manager, looking for Powershell.exe to show up), I'm not seeing the file being created.</p>
  
  <pre><code>powershell.exe -noexit -windowstyle hidden {iis_test.ps1}
  </code></pre>
  
  <p>Nor am I seeing any errors being caught in any of the likely places (event viewer, the command prompt window itself).</p>
  
  <p>Any ideas? Ultimately, my goal is to have a vb winforms thing call these script files, and naturally I thought figuring out the command prompt command would be helpful. <strong>Note</strong> that it is very important that this script be portable, and run on any Windows 2008 Server system (so I need to stay away from third party entities that would require further installation).</p>
  
  <p><strong>EDIT:</strong> I needed to use the -file argument to specify a file to run.</p>