仅使用 AppCmd 在 APPHOST 中列出配置
我需要使用 powershell 在尚未将代码部署到文件系统(可能根本没有,可能存在旧/损坏的 web.configs)的 Web 应用程序上配置 IIS7.5。我希望能够在 APPHOST 级别完成这一切。 (请注意底部有关 Powershell > AppCmd 的使用)。
我可以正确设置所有值,但是,有点勤奋,我还喜欢通过在设置后检索它们来验证这些值是否设置正确。
这是场景: 我可以使用 AppCmd 设置此值,以便使用 /Commit:APPHOST 标志在 APPHOST 级别应用该设置。但是,我还没有找到一种方法来专门在 APPHOST 级别读取这些值。
设置代码成功:
C:\Windows\System32\inetsrv\appcmd.exe set config "webSiteName/webAppName" -section:system.webServer/security/authentication/anonymousAuthentication /enabled:"True" /commit:apphost
但是,我找不到使用 AppCmd(或 Powershell)读取值的方法: 由于文件夹中预先存在的 web.config 已损坏,运行以下 AppCmd 会返回错误(具体错误并不重要,因为它正在读取 WebApp 的 web.config 而不是 ApplicationHost.config/APPHOST):
C:\Windows\System32\inetsrv\appcmd.exe list config "MACHINE/WEBROOT/APPHOST/webSiteName/webAppName" -section:system.webServer/security/authentication/anonymousAuthentication
ERROR ( message:Configuration error
Filename: \\?\c:\inetpub\wwwroot\webSiteName\webAppName\web.config
Line Number: 254
Description: The configuration section 'system.runtime.caching' cannot be read because it is missing a section declaration
. )
注意:我会更喜欢在 Powershell 中完成这一切,而不是使用 AppCmd,因此,如果有人拥有从 Powershell 内部修改位于网站下的 Web 应用程序的匿名身份验证部分的 APPHOST 设置的语法(Get-WebConfiguration 似乎只使用 WebApp web.config),那将是非常棒的,非常感谢!
I have a requirement to use powershell to configure IIS7.5 on WebApplications that have not yet had code deployed (possibly at all, possibly old/broken web.configs exist) to the file system. I would like to be able to do this all at the APPHOST level. (Note at the bottom about use of Powershell > AppCmd).
I can SET all the values properly, however, being somewhat diligent, I like to also validate the values were set properly by retrieving them after setting.
Here's the scenario:
I can set this value using AppCmd so the setting is applied at the APPHOST level using the /Commit:APPHOST flag. However, I havent found a way to READ the values exclusively at the APPHOST level.
Setting the Code is successful:
C:\Windows\System32\inetsrv\appcmd.exe set config "webSiteName/webAppName" -section:system.webServer/security/authentication/anonymousAuthentication /enabled:"True" /commit:apphost
However, I cant find a way to read the values using AppCmd (or Powershell):
Running the following AppCmd returns an error due to the broken pre-existing web.config in the folder (the specific error is unimportant, as it is reading the WebApp's web.config instead of the ApplicationHost.config/APPHOST):
C:\Windows\System32\inetsrv\appcmd.exe list config "MACHINE/WEBROOT/APPHOST/webSiteName/webAppName" -section:system.webServer/security/authentication/anonymousAuthentication
ERROR ( message:Configuration error
Filename: \\?\c:\inetpub\wwwroot\webSiteName\webAppName\web.config
Line Number: 254
Description: The configuration section 'system.runtime.caching' cannot be read because it is missing a section declaration
. )
Note: I would prefer to do this all in Powershell instead of using AppCmd, so if anyone has the syntax for modifying the APPHOST settings for anonymousAuthentication section of a WebApplication, that lives under a Website, from inside Powershell (Get-WebConfiguration seems to only use the WebApp web.config), that would be totally awesome and much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是在 PowerShell 中执行此操作的方法:
Here's how to do this in PowerShell: