在PowerShell中创buildWeb服务器场

我试图在PowerShell中自动创build一个服务器群。 通过手动创build,我得到了以下XML:

<webFarms> <webFarm name="alwaysup" enabled="true"> <server address="alwaysup-blue" enabled="true"> <applicationRequestRouting httpPort="8001" /> </server> <server address="alwaysup-green" enabled="true"> <applicationRequestRouting httpPort="8002" /> </server> <applicationRequestRouting> <healthCheck url="http://alwaysup/up.html" interval="00:00:05" responseMatch="up" /> </applicationRequestRouting> </webFarm> <applicationRequestRouting> <hostAffinityProviderList> <add name="Microsoft.Web.Arr.HostNameRoundRobin" /> </hostAffinityProviderList> </applicationRequestRouting> </webFarms> 

试图通过PS做这件事certificate麻烦,但是:据我所知,没有专门的API来做到这一点( WebFarmSnapin是为旧版本)。

我已经将注意力转移到了IISpipe理Cmdlet上,但只有一半工作。

我有的代码是:

 ##### # Overwriting the server farm ##### Write-Host "Overwriting the server farm $($webFarmName)" $webFarm = @{}; $webFarm["name"] = 'siteFarm' Set-WebConfiguration "/webFarms" -Value $webFarm ##### # Adding the servers ##### Write-Host "Adding the servers" $blueServer = @{} $blueServer["address"] = 'site-blue' $blueServer["applicationRequestRouting"] = @{} $greenServer = @{} $greenServer["address"] = 'site-green' $greenServer["applicationRequestRouting"] = @{} $servers = @($blueServer, $greenServer) Add-WebConfiguration -Filter "/webFarms/webFarm[@name='siteFarm']" -Value $servers ##### # Adding routing ##### Write-Host "Adding the routing configurations" $blueServerRouting = @{} $blueServerRouting["httpPort"] = "8001" Add-WebConfiguration -Filter "/webFarms/webFarm[@name='siteFarm']/server[@address='site-blue']" -Value $blueServerRouting 

这产生

 <webFarms> <webFarm name="siteFarm"> <server address="site-blue" /> <server address="site-green" /> </webFarm> <applicationRequestRouting> <hostAffinityProviderList> <add name="Microsoft.Web.Arr.HostNameRoundRobin" /> </hostAffinityProviderList> </applicationRequestRouting> </webFarms> 

正如你所看到的,它缺less与路由相关的端口。 我甚至还没有开始尝试添加健康检查在这一点上。

我究竟做错了什么? 有没有find一些Cmdlet,这使得这更容易?

相关但没有太多有用的答案(生成的代码PowerShell选项卡保持空)。

在实现SF存在之后,从SO交叉发送,可能更合适。