适用于IIS 7.0的PowerShellpipe理单元IIsProviderSnapIn与Webpipe理

我正在尝试在运行带有Service Pack 2的服务器2008的服务器上安装IIS 7.0的Windows PowerShellpipe理单元 ,因此我可以使用Webpipe理快照 。

安装时我遇到了一个错误

此产品的另一个版本已经安装。 此版本的安装无法继续。 configuration或删除此产品的现有版本。

Get-PSSnapin和Get-Module-ListAvailable都不显示Web WebAdministration ,但是我列出了IIsProviderSnapIn 。 另外, 在Windows 2008 R1上使用PowerShell 2和模块作为IISpipe理答案提供的脚本返回False。

这是WebAdministration的旧版本吗?

这是作为“IIS 7.0的Microsoft Windows PowerShell提供程序”在“程序和function”下列出的吗? 如果是这样,我可以安全地卸载它,并从原始链接安装PowerShellpipe理单元?

(或者,我可以使用IIsProviderSnapIn来获取所有当前正在运行的站点的列表,就像我在WebAdministration模块中的Get-Website ?)

虽然我仍然不确定究竟是什么IIsProviderSnapInpipe理单元与IIsProviderSnapInpipe理相比,我已经结束了一个修改版本的答案https://stackoverflow.com/questions/1924217/powershell-load-webadministration-在-PS1-脚本上都-IIS-7和-IIS-7-5
如果可用,将IIsProviderSnapInIIsProviderSnapInpipe理pipe理单元或模块中,否则使用IIsProviderSnapIn

 $iisVersion = Get-ItemProperty "HKLM:\software\microsoft\InetStp" $useIISProviderSnappin = $False if ($iisVersion.MajorVersion -eq 7) { if ($iisVersion.MinorVersion -ge 5) { Import-Module WebAdministration } else { if(Get-PSSnapIn -Registered | Where {$_.Name -eq "WebAdministration"}) { if (-not (Get-PSSnapIn | Where {$_.Name -eq "WebAdministration"})) { Add-PSSnapIn WebAdministration } } elseif(Get-PSSnapIn -Registered | Where {$_.Name -eq "IIsProviderSnapIn"}) { #older versions of server 2008 don't have the webadministration module! if (-not (Get-PSSnapIn | Where {$_.Name -eq "IIsProviderSnapIn"})) { Add-PSSnapIn IIsProviderSnapIn } $useIISProviderSnappin = $True } else { throw "Unable to import any suitable modules... :( " } } } Function Get-IISWebsite() { if($useIISProviderSnappin) { return dir iis:\sites } else { return Get-Website } }