How can I continue lines of a script block in PowerShell?
<p>I'm trying to write a Powershell function to create an OrganizationalUnit. I'm a PS newbie but I've pieced together:</p>

<pre><code>function makeOU ($cn, $path)
{
  $sb = [scriptblock]::Create(
      "New-ADOrganizationalUnit $cn -path `"$path`"
        -ProtectedFromAccidentalDeletion 0"
    )

  Invoke-Command -ComputerName $server -Credential $Credential `
    -ScriptBlock $sb
}
</code></pre>

<p>But when I invoke this later in the script, I get a message that <code>-ProtectedFromAccidentalDeletion</code> is an unknown cmdlet.  If I make the command one line</p>

<pre><code>"New-ADOrganizationalUnit $cn -path `"$path`" -ProtectedFromAccidentalDeletion 0"
</code></pre>

<p>it works.</p>

<p>As I see it, at the end of </p>

<pre><code>      "New-ADOrganizationalUnit $cn -path `"$path`"
</code></pre>

<p>there is an open parenthesis and an open quote so PS should be looking for more input.  Ending that line with a back tick didn't help.  Nor did converting the argument to <code>Create()</code> to the form <code>@" ... "@</code>.  (This is different from <a href="https://stackoverflow.com/questions/19014514">Why I am getting PowerShell Parsing Error?</a> in that I don't have any back ticks, certainly none with spaces after them.)</p>

<p>If I'm making an newbie error here and there's a better way to pass the function parameters to <code>Invoke-Command</code>, I'm open to rewriting but failing that, how can break the string passed to <code>Create()</code> onto multiple lines?</p>