I would like to execute powershell commands from a Windows console commandline. My method is:
c:\>powershell -Command mypowershellstatment1;mypowershellstatment1;etc
Issue:
In case if a complex powershell command contains powershell pipe operator, then it seems that Windows console interprets it, instead of passing it literally as parameter to the powershell executable.
For example:
c:\>powershell -Command mypowershellstatment1 | anything;mypowershellstatment1;etc
gives the standard console error message "'anything' is not recognized as an internal or external command" operable program or batch file.
Question
How to overcome this issue?
|with^:Get-Something ^| Do-Somethingpowershellfirst and then you will be prompted withPS >prompt where you can enter any powershell commands you want natively without having to worry about escaping.-Commandvalue not surrounded in double quotes? It is a command string.