丢失括号和逗号.
将您的功能称为:
$s = CreateAppPoolScript "name" "user" "pass"
得到:
cscript adsutil.vbs CREATE "w3svc/AppPools/name" IIsApplicationPool
cscript adsutil.vbs SET "w3svc/AppPools/name/WamUserName" "user"
cscript adsutil.vbs SET "w3svc/AppPools/name/WamUserPass" "pass"
cscript adsutil.vbs SET "w3svc/AppPools/name/AppPoolIdentityType" 3
顺便说一句,使用PowerShell的此处字符串也可以使您的函数更易于阅读,因为您无需将所有"
-mark 都加倍:
function CreateAppPoolScript([string]$AppPoolName, [string]$AppPoolUser, [string]$AppPoolPass) { # Command to create an IIS application pool return @" cscript adsutil.vbs CREATE "w3svc/AppPools/$AppPoolName" IIsApplicationPool cscript adsutil.vbs SET "w3svc/AppPools/$AppPoolName/WamUserName" "$AppPoolUser" cscript adsutil.vbs SET "w3svc/AppPools/$AppPoolName/WamUserPass" "$AppPoolPass" cscript adsutil.vbs SET "w3svc/AppPools/$AppPoolName/AppPoolIdentityType" 3 "@ }