title: PowerShell pass arguments with quotes
body: <p>Have very useful script named <code>sudo.ps1</code>:</p>
  
  <pre><code>$w=""; foreach($a in $args[1..($args.length-1)] ){ $w += " " + $a }; $w
  Start-Process $args[0] -ArgumentList $w -Verb RunAs -Wait 
  </code></pre>
  
  <p>but it can't handle complex command</p>
  
  <pre><code>./sudo.ps1 schtasks /create /F /TN "$vpn_name Connection Update" /TR "Powershell.exe -noexit -command D:\vpn-route.ps1" /SC ONEVENT /EC Application /MO "*[System[(Level=4 or Level=0) and (EventID=20225)]] and *[EventData[Data='$vpn_name']]" /RL HIGHEST 
  </code></pre>
  
  <p>Problem is in obfuscated quotes. In <code>sudo.ps1</code> quotes are opened: </p>
  
  <pre><code> /create /F /TN VPN-Kosmos6 Connection Update /TR Powershell.exe -noexit -command D:\vpn-route.ps1 /SC ONEVENT /EC Application /MO *[System[(Level=4 or Level=0) and (EventID=20225)]] and *[EventData[Data='VPN-Kosmos6']] /RL HIGHEST
  </code></pre>
  
  <p>Command executed with no error, but does no work. How can it be fixed?</p>