Pipe character from PowerShell string command is not recognized in Csharp C# code Pipe character from PowerShell string command is not recognized in Csharp C# code powershell powershell

Pipe character from PowerShell string command is not recognized in Csharp C# code


It works if I add additional quotes:

var cmd2 = client.CreateCommand(                    "powershell.exe -executionPolicy bypass; " +                    "\"Get-Process notepad | Stop-Process\"; " +                    "exit ;");