我有一个停止网站的脚本:
param($HostName = "localhost", $SiteName)
$server = $HostName
$siteName = $SiteName
$iis = [ADSI]"IIS://$server/W3SVC"
$site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer" -AND $_.ServerComment -eq $siteName}
$site.start()
# SIG # Begin signature block ...
但是当我在具有高安全策略的服务器上运行脚本时,我收到了这个错误:
The following exception was thrown when trying to enumerate the collection: "Unknown error (0x80005000)".
At D:\DeploymentScripts\Common\StopSite.ps1:6 char:8
+ $site = <<<< $iis.psbase.children | where { $_.keyType -eq "IIsWebServer" -AND $_.ServerComment -eq $siteName}
+ CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
+ FullyQualifiedErrorId : ExceptionInGetEnumerator
从我读到的内容来看,如果我无权访问 IIS,但我以管理员身份运行脚本,这可能不会授予我所需的访问权限吗?
网络管理模块是否提供更多访问权限?我没有导入它,因为我不必在其他服务器上执行此操作,如果我需要导入 webadministration 还有另一个问题,当我尝试时我收到错误消息说 WebAdministrationAliases.ps1 没有数字签名.. .
我已经在其他服务器上测试了脚本没有问题,但是这个脚本有更严格的策略,如上所述,它不是更改策略的选项。
我在带有 IIS 7.5 的 Windows 服务器 2008 R2 上运行它。