2009-04-15 3 views
0

私はpowershellを使用して複数のサーバーバインドを単一のWebサイトに追加しようとすると実際の問題を抱えています!powershellを使用して複数のServerBindingをIIS6に追加するにはどうすればよいですか?

は現在、私は次のコードを持っている:

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

単一値を持つプロパティのために働いているが、私は、複数として追加する方法を動作するように見えることはできません。

Iが配列として渡す

  1. を試みた
  2. (コンマ区切り文字列として渡すようセミコロン区切り文字列を渡す
  3. を(1つのホスト・エントリにすべての文字列を入れる)(例外がスロー)二回プットを実行している1つのホストエントリ)
  4. にすべての文字列を置きます(私だけがしてきた最後のホストエントリ)

の節約Googleで検索を実行するが、何も動作していないようだ!

助けてください! :(ここでは、www.iis.netからのIIS PowerShellプロバイダーをインストールする場合は、それの道簡単に時間を持っています

答えて

2

あなたが行く:

$site = [adsi]"IIS://localhost/w3svc/$siteid" 
$site.ServerBindings.Insert($site.ServerBindings.Count, ":80:$hostheader") 
$site.SetInfo() 
+0

夢のように働いてくれてありがとう!:) –

0

http://www.iis.net/1664/ItemPermalink.ashx

[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". 
+0

として、私はIIS6を使用していますが、これは本当にうまくいかないでしょう!!!!ありがとうと、 –