0

移至 Windows 8,我正在尝试在 powershell 中运行以下命令

# Load the Web Management and Administration Assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Management")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")

$ServerManager = New-Object Microsoft.Web.Administration.ServerManager
$defaultSite = $ServerManager.Sites["Default Web Site"];

Sites 数组为空

跑步

appcmd.exe list sites

SITE "Default Web Site" (id:1,bindings:http/*:80:,state:Started)

这适用于带有 Windows 7 的 IIS 7

谢谢,

4

1 回答 1

3

Well lots of trawling through the web produced the following solution

Using

$computer = gc env:computername
$ServerManager = [Microsoft.Web.Administration.ServerManager]::OpenRemote($computer.ToLower())
$defaultSite = $ServerManager.Sites["Default Web Site"];

Produced the desired result. Hope this helps someone else in the future.

于 2013-02-18T02:26:38.227 回答