title: PowerShell vs PowerShell ISE
body: <p>I have a problem of running my PowerShell script in Task Scheduler. 
  I created script in PowerShell ISE and it works fine.</p>
  
  <p>But when I run it by PowerShell it reports some mistakes.</p>
  
  <p>Do you have any ideas why this can happen?</p>
  
  <p>I have tried to create a single line file with</p>
  
  <pre><code>powershell_ise.exe -File D:\script.ps1
  </code></pre>
  
  <p>or </p>
  
  <pre><code>powershell.exe -File D:\script.ps1
  </code></pre>
  
  <p>But neither of it works.
  I have checked policy, but I have it unrestricted.</p>
  
  <p>I have tried to run </p>
  
  <pre><code>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -Command d:\Script.ps1
  </code></pre>
  
  <p>in PowerShell ISE and it works fine.</p>
  
  <p>When I run it in PowerShell it shows error:</p>
  
  <pre>The term '▬' is not recognized as the name of a cmdlet, function, script file,
  or operable program. Check the spelling of the name, or if a path was included,
  verify that the path is correct and try again.
  At line:1 char:1</pre>
  
  <pre><code>$datetime = Get-Date -f yyyMMdd
  
  $strFileName = "c:\test\BS_" + $datetime + ".txt"
  
  if (Test-Path $strFileName) {
    exit
  } else {
    exit
  }
  
  ...
  </code></pre>