我在尝试使用powershell将多个服务器绑定添加到单个网站时遇到了实际问题!
目前我有以下代码:
function UpdateMetaBaseProperties($dirEntry, $Properties)
{
foreach($Prop in $Properties)
{
$KeyValue = $Prop.Split('=');
$dirEntry.psbase.Invoke("Put", ($KeyValue[0], $KeyValue[1]));
$dirEntry.psbase.Invoke("SetInfo");
Write-Host "Setting property: $KeyValue";
}
}
这适用于单值属性,但我似乎无法解决如何添加多个。
我试过
我一直在谷歌搜索搜索,但似乎没有任何作用!
请帮忙!! :(
答案 0 :(得分:2)
你走了:
$site = [adsi]"IIS://localhost/w3svc/$siteid"
$site.ServerBindings.Insert($site.ServerBindings.Count, ":80:$hostheader")
$site.SetInfo()
答案 1 :(得分:0)
如果您从www.iis.net(http://www.iis.net/1664/ItemPermalink.ashx)安装IIS powershell提供程序,您将有更轻松的时间
[E] PS> add-pssnapin webadministration
[E] PS> new-webbinding -?
NAME
New-WebBinding
SYNOPSIS
Adds a new Web site binding to an existing Web site.
SYNTAX
New-WebBinding [[-Name] <String>] [-Protocol <String>] [-Port <UInt32>] [-IPAddress <String>] [-HostHeader <String>
] [-Force] [-WarningAction <ActionPreference>] [-WarningVariable <String>] [<CommonParameters>]
DESCRIPTION
Adds a new Web site binding to an existing Web site.
RELATED LINKS
REMARKS
To see the examples, type: "get-help New-WebBinding -examples".
For more information, type: "get-help New-WebBinding -detailed".
For technical information, type: "get-help New-WebBinding -full".