我正在尝试使用 powershell 控制 IIS 应用程序中的绑定。我想使用脚本创建一个同时包含 http 和 https 绑定的站点。
这是我迄今为止所拥有的:
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$hostname,
[Parameter(Mandatory=$True,Position=2)]
[string]$installPath,
[Parameter(Mandatory=$False,Position=3)]
[string]$ip
)
Import-Module WebAdministration
$appPoolName = $hostname + 'Pool'
$port = 80
$hostRecord = $hostname+'.example.com'
$bindings = @{protocol="http";bindingInformation=$ip + ":"+ $port + ":" + $hostRecord}
New-Item IIS:\AppPools\$appPoolName
Set-ItemProperty IIS:\AppPools\$appPoolName managedRuntimeVersion v4.0
New-Item IIS:\Sites\$hostname -Bindings $bindings -PhysicalPath $installPath
Set-ItemProperty IIS:\Sites\$hostname -Name applicationPool -Value $appPoolName
Run Code Online (Sandbox Code Playgroud)
如何将绑定添加到我的$bindings变量/使用其他一些机制来实现我的目标?
powershell ×1