How to split an "if" condition over multiline lines with comments
<p>I cannot achieve to split an "if" condition over multiple lines in PowerShell <strong>WITH</strong> comments, see example:</p>

<pre><code>If ( # Only do that when...
    $foo # foo
    -and $bar # AND bar
)
{
    Write-Host foobar
}
</code></pre>

<p>This generates the following error:</p>

<blockquote>
  <p>Missing closing ')' after expression in 'if' statement.</p>
</blockquote>

<p>Adding the <code>`</code> character does not work:</p>

<pre><code>If ( ` # Only do that when...
    $foo ` # foo
    -and $bar ` # AND bar
)
{
    Write-Host foobar
}
</code></pre>

<p>I get a:</p>

<blockquote>
  <p>Unexpected token '` # foo' in expression or statement.</p>
</blockquote>

<p>The only way I've found is to remove the comments:</p>

<pre><code>If ( `
    $foo `
    -and $bar `
)
{
    Write-Host foobar
}
</code></pre>

<p>But I am sure PowerShell offers a way to do what others scripting languages can: I just seem cannot find it...</p>