powershell - 通过appcmd检查iis模块是否存在

标签 powershell iis deployment web-config

我需要检查是否为我的站点安装了自定义 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/iis/get-started/whats-new-in-iis-10/iisadministration-powershell-cmdlets

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/

相关文章:

Powershell Read-Host 无法正确加法或乘法?

sql-server - 语义 Web - 将应用程序数据直接存储在 RDF 中或存储在 SQL 中并稍后导出/导入

javascript - 使用原始文件部署 Angular-App

php使用ip地址显示持有页面

http - 从 Windows Powershell 发送 HTTP 请求的最佳方式是什么?

azure - BringOwnFeatureNotEnabled 错误代码在 Azure 中意味着什么

.net - 在 ASP.NET 中使用更少的内存

model-view-controller - 如何在 IIS7 中启用 DELETE 动词?

python - djangoproject.com 如何部署到产品?我应该打包我的 django 项目来部署它吗?

powershell - 使用 Powershell 对 CSV 文件进行排序