通过 appcmd 检查 iis 模块是否存在
Check if iis module exist by appcmd
我需要检查我的站点是否安装了自定义 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}}
根据您的描述,我建议您可以尝试使用以下命令来实现您的要求:
appcmd.exe list config "{yoursitename}" -section:system.webServer/modules /text:[name='myModuleName'].type
我需要检查我的站点是否安装了自定义 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}}
根据您的描述,我建议您可以尝试使用以下命令来实现您的要求:
appcmd.exe list config "{yoursitename}" -section:system.webServer/modules /text:[name='myModuleName'].type