Microsoft.Web.Administration.ServerManager连接到IIS Express而不是完整的IIS

时间:2014-09-12 15:51:09

标签: powershell iis iis-express

我正在使用它创建ServerManager的实例:

[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$serverManager = New-Object Microsoft.Web.Administration.ServerManager

运行$serverManager.ApplicationPools | Select -Property Name时,我得到:

Name
----
Clr4IntegratedAppPool
Clr4ClassicAppPool
Clr2IntegratedAppPool
Clr2ClassicAppPool
UnmanagedClassicAppPool

运行$serverManager.Sites | Select -Property Bindings时,我得到:

Bindings
--------
{[http] :8080:localhost}
{[http] *:23700:localhost}
{[http] *:58996:localhost}
{[http] *:62159:localhost}
{[http] *:51643:localhost}
{[http] *:64256:localhost}
{[http] *:50934:localhost}
{[http] *:53107:localhost}
{[http] *:49414:localhost}
{[http] *:59074:localhost}
{[http] *:61886:localhost}
{[http] *:57546:localhost}
{[http] *:63087:localhost}
{[http] *:63838:localhost}
{[http] *:63727:localhost}
{[http] *:60172:localhost}

所以它似乎是连接到IIS Express而不是我的完整IIS。如何让它连接到完整的IIS呢? documentation没有列出任何接受参数的重载,至少没有用于公共用途。

1 个答案:

答案 0 :(得分:3)

DLL有两个版本。完整IIS包含7.0.0.0,IIS Express包含7.9.0.0。这两个版本也都在GAC中。

指定版本7.0.0.0允许访问完整的IIS:

[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL")

与此同时,我还发现LoadWithPartialName已被弃用,这是目前的做法:

Add-Type -AssemblyName "Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"