Why Native Commands Fail In Powershell
Powershell

You probably already know that not all native commands work equally well in PowerShell. Have a look here:

find /I /N "dir" *.ps1

In cmd.exe, this line finds all occurrences of "dir" in all PowerShell scripts that are located in the current path. In PowerShell, the very same command will fail because special characters can confuse the PowerShell parser.

" The beginning (or end) of quoted text

  1. The beginning of a comment

$ The beginning of a variable

& Reserved for future use

( ) Parentheses used for sub-expressions

; Statement separator

{ } Script block

| Pipeline separator

` Escape character

One workaround is to execute the line in good old cmd.exe and then enclose the command in single quotes:

cmd.exe /c 'find /I /N "dir" *.ps1'
Bibliography
1. from www.powershell.com

Old Cmd S In Powershell

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License