gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 11:27:33 25 4
gpt4 key购买 nike

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

 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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com