title: How to run PowerShell on one line?
body: <p>As per <a href="https://stackoverflow.com/questions/22258668/how-to-condense-powershell-script-to-fit-on-a-single-line">this answer</a>, PowerShell statements can be separated with semicolins. </p>
  
  <p>Here's a snippet of the script I'm working with (somewhat redacted for simplification):</p>
  
  <pre><code>Add-Type -AssemblyName System.Web;
  
  $server = "http://website.com/index.php";
  
  foreach ($path in [System.IO.Directory]::EnumerateFiles("C:\path\to\dir","*.xml","AllDirectories")) {
  
    try {
      $oXml = New-Object System.XML.XMLDocument;
      $oXml.Load($path);
      &lt;more commands here&gt;;
    } catch {}
  
  }
  </code></pre>
  
  <p>Here's one of my many attempts at condensing it:</p>
  
  <pre><code>powershell -ExecutionPolicy Bypass -Command "Add-Type -AssemblyName System.Web; $server = 'http://website.com/index.php'; foreach ($path in [System.IO.Directory]::EnumerateFiles("C:\path\to\dir","*.xml","AllDirectories")) { try { $oXml = New-Object System.XML.XMLDocument; $oXml.Load($path); &lt;more commands here&gt;;} catch {}}"
  </code></pre>
  
  <p>And here are the errors returned by the cmd:</p>
  
  <pre><code>At line:1 char:140
  + ... hp'; foreach ($path in [System.IO.Directory]::EnumerateFiles(C:\path ...
  +                                                                  ~
  Missing ')' in method call.
  At line:1 char:140
  + ... ry]::EnumerateFiles(C:\path\to\dir,*.xml,A ...
  +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Unexpected token 'C:\path\to\dir' in expression or statement.
  At line:1 char:140
  + ... hp'; foreach ($path in [System.IO.Directory]::EnumerateFiles(C:\path ...
  +                                                                  ~
  Missing closing ')' after expression part of foreach loop.
  At line:1 char:181
  + ... y]::EnumerateFiles(C:\path\to\dir,*.xml,Al ...
  +                                                                 ~
  Missing argument in parameter list.
  At line:1 char:202
  + ... \path\to\dir,*.xml,AllDirectories)) { try  ...
  +                                                                 ~
  Unexpected token ')' in expression or statement.
  At line:1 char:203
  + ... path\to\dir,*.xml,AllDirectories)) { try { ...
  +                                                                 ~
  Unexpected token ')' in expression or statement.
      + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
      + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
  </code></pre>
  
  <p>How can I (properly) condense the above PowerShell script into one line?</p>