<p>I am trying to do some string concatenation/formatting, but it's putting all the parameters into the first placeholder.</p>

<p><strong>Code</strong></p>

<pre><code>function CreateAppPoolScript([string]$AppPoolName, [string]$AppPoolUser, [string]$AppPoolPass)
{
    # Command to create an IIS application pool
    $AppPoolScript = "cscript adsutil.vbs CREATE ""w3svc/AppPools/$AppPoolName"" IIsApplicationPool`n"
    $AppPoolScript += "cscript adsutil.vbs SET ""w3svc/AppPools/$AppPoolName/WamUserName"" ""$AppPoolUser""`n"
    $AppPoolScript += "cscript adsutil.vbs SET ""w3svc/AppPools/$AppPoolName/WamUserPass"" ""$AppPoolPass""`n"
    $AppPoolScript += "cscript adsutil.vbs SET ""w3svc/AppPools/$AppPoolName/AppPoolIdentityType"" 3"

    return $AppPoolScript
}
$s = CreateAppPoolScript("name", "user", "pass")
write-host $s
</code></pre>

<p><strong>Output</strong></p>

<pre class="lang-none prettyprint-override"><code>cscript adsutil.vbs CREATE "w3svc/AppPools/name user pass" IIsApplicationPool
cscript adsutil.vbs SET "w3svc/AppPools/name user pass/WamUserName" ""
cscript adsutil.vbs SET "w3svc/AppPools/name user pass/WamUserPass" ""
cscript adsutil.vbs SET "w3svc/AppPools/name user pass/AppPoolIdentityType" 3
</code></pre>

[{'answer_id': 22770, 'author': 'Paul Roub', 'author_id': 1324, 'author_profile': 'https://Stackoverflow.com/users/1324', 'pm_score': 7, 'selected': True, 'text': '<p>Lose the parentheses and commas.  </p>\n\n<p>Calling your function as:</p>\n\n<pre><code>$s = CreateAppPoolScript "name" "user" "pass"\n</code></pre>\n\n<p>gives:</p>\n\n<pre class="lang-none prettyprint-override"><code>cscript adsutil.vbs CREATE "w3svc/AppPools/name" IIsApplicationPool\ncscript adsutil.vbs SET "w3svc/AppPools/name/WamUserName" "user"\ncscript adsutil.vbs SET "w3svc/AppPools/name/WamUserPass" "pass"\ncscript adsutil.vbs SET "w3svc/AppPools/name/AppPoolIdentityType" 3\n</code></pre>\n'}, {'answer_id': 22946, 'author': 'Steven Murawski', 'author_id': 1233, 'author_profile': 'https://Stackoverflow.com/users/1233', 'pm_score': 2, 'selected': False, 'text': "<p>Paul's right.<br>\nIn PowerShell, function parameters are not enclosed in parenthesis.  (Method parameters still are.)<br>\nYour initial call was just passing one big array to the function, rather than the three separate parameters you wanted.</p>\n"}, {'answer_id': 40890, 'author': 'Emperor XLII', 'author_id': 2495, 'author_profile': 'https://Stackoverflow.com/users/2495', 'pm_score': 3, 'selected': False, 'text': '<p>By the way, using a PowerShell <a href="http://blogs.msdn.com/powershell/archive/2006/07/15/Variable-expansion-in-strings-and-herestrings.aspx" rel="noreferrer">here-string</a> might make your function a little easier to read as well, since you won\'t need to double up all the <code>"</code>-marks:</p>\n\n<pre><code>function CreateAppPoolScript([string]$AppPoolName, [string]$AppPoolUser, [string]$AppPoolPass)\n{\n  # Command to create an IIS application pool\n  return @"\ncscript adsutil.vbs CREATE "w3svc/AppPools/$AppPoolName" IIsApplicationPool\ncscript adsutil.vbs SET "w3svc/AppPools/$AppPoolName/WamUserName" "$AppPoolUser"\ncscript adsutil.vbs SET "w3svc/AppPools/$AppPoolName/WamUserPass" "$AppPoolPass"\ncscript adsutil.vbs SET "w3svc/AppPools/$AppPoolName/AppPoolIdentityType" 3\n"@\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/22732', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/636/']