Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

-Command does not run

11 views
Skip to first unread message

paul.her...@gmail.com

unread,
Aug 4, 2017, 10:52:45 AM8/4/17
to
Running the following from cmd.exe appears to do nothing. No output. No error message.

C:>powershell -NoProfile -Command "& { Get-ChildItem -Path 'C:/src/t/' ^| Remove-Item -Recurse -WhatIf }"

Removing the invocation operator appears to simply make the command be printed.

C:>powershell -NoProfile -Command "{ Get-ChildItem -Path 'C:/src/t/' ^| Remove-Item -Recurse -WhatIf }"
Get-ChildItem -Path 'C:/src/t/' ^| Remove-Item -Recurse -WhatIf

The pipe (VERTICAL BAR) character is escaped. What's going on here?

JJ

unread,
Aug 5, 2017, 12:04:12 PM8/5/17
to
Because the escape character (^) is within double-quotes. The escape
character is passed as is to the PowerShell's command line. Thus the actual
command executed in PowerShell is:
0 new messages