title: How to execute powershell commands (not from ps1 file) from cmd.exe
body: <p>I am trying to execute powershell if-else from cmd. 
  For example to check the number of files, that has "temp" in its name in D: drive,I used,</p>
  
  <pre><code>if(($i=ls D:\* | findstr /sinc:Temp).count -ne 0 ) {Write-Host $i}
  </code></pre>
  
  <p>This works fine from PS windows</p>
  
  <p>But if want to do the same from cmd, How do i do it?
  I tried </p>
  
  <pre><code>powershell -noexit if(($i=ls D:\* | findstr /sinc:Temp).count -ne 0 ) {Write-Host $i}
  </code></pre>
  
  <p>which did not work unfortunately. </p>