【问题标题】:How to use WMI on Powershell to read IIS settings?如何在 Powershell 上使用 WMI 读取 IIS 设置?
【发布时间】:2018-02-15 05:29:00
【问题描述】:

我是 wmi、powershell、IIS 和英语的初学者。

通常,我在 powershell 上使用 get-wmiobject,如下 SampleCode。
目标:WindowsServer 2012、IIS8
Powershell 运行客户端:Windows7ProSP1x64、Powershell v5、.NET 4.6.1

Get-WmiObject -Query "Select * from Win32_QuickFixEngineering" `
  -Namespace root/cimv2 -ComputerName $hostname -Credential $cred

但对于 IIS,我不知道如何使用该命令行开关。

有任何命名空间收集吗?如何在 powershell 上将搜索 ClassName 用于 IIS?

【问题讨论】:

    标签: powershell iis wmi


    【解决方案1】:

    您不必必须使用 WMI(我认为这对 IIS 没有意义,但不要引用我的话)。你可以使用webadministration模块:

    Import-Module WebAdministration
    Get-ChildItem –Path IIS:\AppPools
    New-Item –Path IIS:\AppPools\MyAppPool
    Get-ItemProperty IIS:\AppPools\MyAppPool | select *
    Set-ItemProperty -Path IIS:\AppPools\MyAppPool -Name managedRuntimeVersion -Value 'v4.0'
    Remove-WebAppPool -Name MyAppPool
    

    或者您可以使用模块中的各种 cmdlet 来管理 IIS

    【讨论】:

    • 感谢您的回答和编辑我的问题,4c74356b41。
    • 这个答案对您有帮助吗?如果是,你应该考虑投票\接受这个答案。
    • 是的,您的回答很有帮助。我点击了复选标记。
    猜你喜欢
    • 2021-02-19
    • 1970-01-01
    • 1970-01-01
    • 2010-10-26
    • 2014-06-24
    • 2011-02-01
    • 1970-01-01
    • 2010-11-05
    • 2018-01-08
    相关资源
    最近更新 更多