我需要检查是否为我的站点安装了自定义 IIS 模块。
我运行以下命令:
C:\windows\system32\inetsrv\appcmd.exe list config 'mySite' /section:system.webServer/modules /[name="myModuleName"]
并查看错误:
ERROR ( message:The attribute "[name=myModuleName]" is not supported in the current command usage. )
我做错了什么?
最佳答案
如果您使用的是当前版本的 IIS(7 或更高版本),那么为什么不直接使用 IIS Admin 或 Web Admin cmdlet,vs app 命令来完成这项工作呢?
https://docs.microsoft.com/en-us/powershell/module/webadministration/?view=win10-ps
https://octopus.com/blog/iis-powershell
https://blogs.iis.net/jeonghwan/iis-powershell-user-guide-comparing-representative-iis-ui-tasks
# [IIS] Configure Module elements and properties which are configured in globalModules section
# Case1: List all native modules
(Get-WebConfiguration //globalmodules).collection -PSPath iis:
# Case4: List all of enabled modules from 'server' level
(get-webconfiguration //modules -PSPath iis:).collection -PSPath iis:
# Case5: Get the attributes for a specific module
$modules=(get-webconfiguration //modules -PSPath iis:).collection
$modules | foreach {if ($_.name -eq "cgiModule") { $_.attributes | select name, value}}
关于powershell - 通过appcmd检查iis模块是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56890989/