title: Can't run Loops or Conditional statements inside Powershell Script on remote computer
body: <p>I want to run a Powershell script on a remote computer from a docker container.
  I can't use the WSManConnectionInfo library because of compatibility issues with my base docker image, so I have to use Powershell commands.
  I am able to run basic commands well. Like:</p>
  <pre><code>                   powershell.AddCommand(&quot;invoke-command&quot;);
                     powershell.AddParameter(&quot;ComputerName&quot;, &quot;computerName&quot;);
                     powershell.AddParameter(&quot;Credential&quot;, creds);
                     String testScript = File.ReadAllText(&quot;\\Scripts\\TestScript.ps1&quot;);
                     ScriptBlock filter = ScriptBlock.Create(testScript);
                     powershell.AddParameter(&quot;ScriptBlock&quot;, (filter));
                     powershell.AddParameter(&quot;ArgumentList&quot;, new object[] { &quot;C:\\&quot; });
                     powershell.Invoke()
  </code></pre>
  <p>The TestScript file looks like this:</p>
  <pre><code>param(${destination})
  if(condition1){
  New-Item -Path ${destination} -Name &quot;TestFolder&quot; -ItemType &quot;directory&quot;}
  </code></pre>
  <p>Now, the script is working fine without the if statement, but it throws the following error when trying with that:</p>
  <blockquote>
  <p>Only a script block that contains exactly one pipeline or command can be converted. Expressions or control structures are not permitted. Verify that the script block contains exactly one pipeline or command.'</p>
  </blockquote>
  <p>Can anyone help me with that?</p>