【问题标题】:Restart IIS6 application pool - ADSI error重新启动 IIS6 应用程序池 - ADSI 错误
【发布时间】:2010-07-14 18:44:03
【问题描述】:

不确定 eff' 有什么问题!我在 Windows 7 上使用 Powershell 2.0。同样的脚本在 Windows XP 上工作,我只是错过了什么吗?

$server = "server1-vm1.prod.ds.russell.com"
$name = "Superduper_Reports"
$iis = [ADSI]"IIS://$server/W3SVC/AppPools/$name"
$iis.psbase.invoke("recycle")

错误(我觉得调用看起来没问题?):

Exception calling "Invoke" with "2" argument(s): "Unknown error (0x80005000)"
At line:3 char:19
+ $iis.psbase.invoke <<<< ("recycle")
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

当刚刚运行 $iis 变量时,我得到这个错误:

The following exception occurred while retrieving member "PSComputerName": "Unknown error (0x80005000)"
    + CategoryInfo          : NotSpecified: (:) [format-default], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember,Microsoft.PowerShell.Commands.FormatDefaultCommand

哇!我宁愿使用 ADSI 而不是 WMI!有什么帮助吗? :)

【问题讨论】:

    标签: powershell powershell-2.0


    【解决方案1】:

    我认为您可以为此使用WebAdministration 模块

    Import-Module WebAdministration
    Get-Command -Module WebAdministration
    Get-ChildItem IIS:
    

    您会发现很多用于管理 IIS 的 Cmdlet 和一个新的驱动器 IIS:

    你会在this Microsoft Web site找到一些解释。

    【讨论】:

    • 谢谢!您介意修正您的 sn-p 中的错字吗?将 d 添加到 Get-ChildItem IIS:
    【解决方案2】:

    这个question 有一个WMI 脚本,据说可以工作。

    另外,ADSI 等价物看起来像这样......

    http://geekswithblogs.net/Lance/archive/2010/12/16/powershell-ndash-recycle-all-iis-app-pools.aspx

    function Recycle-AppPools {
    
        param(
        [string] $server = "3bhs001",
        [int] $mode = 1, # ManagedPipelineModes: 0 = integrated, 1 = classic
        ) 
    
        $iis = [adsi]"IIS://$server/W3SVC/AppPools"
        $iis.psbase.children | %{ 
            $pool = [adsi]($_.psbase.path); 
            if ($pool.AppPoolState -eq 2 -and $pool.ManagedPipelineMode -eq $mode) {
               # AppPoolStates:  1 = starting, 2 = started, 3 = stopping, 4 = stopped          
               $pool.psbase.invoke("recycle") 
            }
       }
    
    }
    

    但是,您无法回收已停止的 AppPool,因此您需要进行检查。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-19
      • 2012-03-28
      • 2011-10-17
      • 2011-09-26
      • 2013-09-28
      • 2011-11-18
      • 1970-01-01
      相关资源
      最近更新 更多