Powershell 为所有应用程序池设置 ManagedPipeline

标签 powershell iis-7

我有一个命令可以列出机器上的所有应用程序池:

 Get-WmiObject -namespace "root/MicrosoftIISv2" -class IIsApplicationPool |Select-Object -property @{N="Name";E={$name = $_.Name; $name.Split("/")[2] }} | Format-Table

我想在盒子上设置每个应用程序池的托管管道。我试过这个:
Get-WmiObject -namespace "root/MicrosoftIISv2" -class IIsApplicationPool |Select-Object -property @{N="Name";E={$name = $_.Name; $name.Split("/")[2] }} | ForEach-Object {cmd /c "c:\windows\system32\inetsvr\appcmd.exe set apppool $name /managedPipleineMode:"Classic"'}

这给了我一个“找不到指定的路径”的错误。任何想法我怎么能这样工作?

最佳答案

为了设置 Managed Pipeline 模式(或 AppPool 的任何属性),您需要使用 Set-ItemProperty。但它比这更有趣:

  • Set-ItemProperty 将 Path 作为其输入。 Get-ChildItem 将
    回您收藏ConfigurationElement对象,而不是路径
    字符串。
  • ManagedPipelineMode 在内部存储为整数,因此
    你必须知道正确的“魔术”数字才能传入。
    幸运的是,已记录在案 here ,在“备注”部分。

  • 这对我有用:
    Import-Module WebAdministration
    Get-ChildItem IIS:\AppPools |
        Select-Object -ExpandProperty PSPath |
        ForEach-Object { Set-ItemProperty $_ ManagedPipelineMode 1 }
    

    关于Powershell 为所有应用程序池设置 ManagedPipeline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12750043/

    相关文章:

    windows - 使用 PowerShell 将击键发送到特定窗口

    powershell - 通过Powershell运行远程进程

    iis-7 - 如何使用 MSBuild Extension Pack 创建带有应用程序的网站

    asp.net - 如何增加url的最大长度?

    list - 从Powershell列表中选择最后一项

    powershell - 如何在返回名称与驱动器相关的文件时查询临时 PS 驱动器?

    .net - 如何将字符串拆分为不带多个空格的字符串数组

    performance - 如何有效地增加 IIS 7 中应用程序池的内存和缓存大小

    asp.net - HTTP 403 禁止 : Access is denied ASP. NET Web API

    html - 如何从服务器上的 img src 属性记录 url 变量(查询字符串)