I can't seem to run PowerShell code correctly with quotes. I have double quotes so the C# will see it as one quote, but escape it. But then the problem occurs, we write the variable onto the screen and it has quotes, as you would guess, but when I put that into the process the quotes just, disappear.
string var = @"function blink {while ($a -ne 1) {$color = get-random -max 17 -min 1
switch($color) {
""1"" {[console]::BackgroundColor = ""Black""}
""2"" {[console]::BackgroundColor = ""DarkBlue""}
""3"" {[console]::BackgroundColor = ""DarkGreen""}
""4"" {[console]::BackgroundColor = ""DarkCyan""}
""5"" {[console]::BackgroundColor = ""DarkRed""}
""6"" {[console]::BackgroundColor = ""DarkMagenta""}
""7"" {[console]::BackgroundColor = ""DarkYellow""}
""8"" {[console]::BackgroundColor = ""Gray""}
""9"" {[console]::BackgroundColor = ""DarkGray""}
""10"" {[console]::BackgroundColor = ""Blue""}
""11"" {[console]::BackgroundColor = ""Green""}
""12"" {[console]::BackgroundColor = ""Cyan""}
""13"" {[console]::BackgroundColor = ""Red""}
""14"" {[console]::BackgroundColor = ""Magenta""}
""15"" {[console]::BackgroundColor = ""Yellow""}
""16"" {[console]::BackgroundColor = ""White""}}
}}
blink";
Console.WriteLine(var);
Console.ReadLine();
System.Diagnostics.Process.Start("powershell.exe", @"powershell.exe -ExecutionPolicy Bypass -Command {" + var + "}");