How do I pass multiple string parameters to a PowerShell script?

后端 未结 3 469
不思量自难忘°
不思量自难忘° 2021-02-01 14:41

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

Code

function C         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-01 15:28

    By the way, using a PowerShell here-string might make your function a little easier to read as well, since you won't need to double up all the "-marks:

    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
    "@
    }
    

提交回复
热议问题