I'm new to Powershell and I found it difficult to tell my first powershell commandline (powershell_1) to : start a new powershell commandline (powershell_2) & let it (the powershell_2) execute my multiline script (written under powershell).
My script is :
$wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop;
$wshell.Popup("Are you looking at me?",0,"Hey!",48+4);
The code I'am using to launch the first powershell commandline and set things to work as intended
Process powershell_1 = new Process();
powershell_1.StartInfo.FileName = "powershell";
string argPowershell_2 = "help";
powershell_1.StartInfo.Arguments = "Start-Sleep -Milliseconds 500; start powershell -argumentlist \" "+ argPowershell_2 + " \"";
MessageBox.Show(powershell_1.StartInfo.Arguments);
powershell_1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
powershell_1.Start();
In the example above, I could tell the 2nd commandline to execute help in the second one. I'm looking for a good way to escape quotes problems and tell it in a correct manner how to execute myscript instead.
EDIT
Ps : I'm not trying to pass a path of a someScript.ps to the second powershell commandline. I want to pass it literally, in multiline format.