为什么Set-ItemProperty对Windows 10下的IIS应用程序不起作用? [英] Why does Set-ItemProperty have no effect for IIS applications under Windows 10?

查看:290
本文介绍了为什么Set-ItemProperty对Windows 10下的IIS应用程序不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的大多数Web应用程序都包含Deploy.ps1 Powershell脚本. Octopus Deploy使用此功能在生产部署期间配置应用程序,但我们也使用它来设置开发人员的本地IIS设置.在Windows 7,Windows 8.1和我们所有的Win2012生产服务器上都可以正常工作.

Most of our web applications include a Deploy.ps1 Powershell script. Octopus Deploy uses this to configure apps during production deployments, but we also use it to set up developers' local IIS settings. Works absolutely fine on Windows 7, Windows 8.1, and on all our Win2012 production servers.

它在Windows 10上不起作用,这似乎是因为Set-ItemProperty cmdlet无效.没有错误消息或任何内容,它什么都不做.

It's not working on Windows 10, and this appears to be because the Set-ItemProperty cmdlet has no effect. No error message or anything, it just doesn't do anything.

IIS站点api.example.com已经存在,我们正在使用Powershell创建/myapp应用程序,然后将应用程序的物理路径更改为D:\ Projects \ Demo

The IIS site api.example.com already exists, and we're using Powershell to create the /myapp application and then change the application's physical path to D:\Projects\Demo

PS C:\> IIS:
PS IIS:\> cd Sites\api.example.com
PS IIS:\Sites\api.example.com> New-WebApplication myapp -site api.example.com -PhysicalPath C:\inetpub\wwwroot

Name             Application pool   Protocols    Physical Path
----             ----------------   ---------    -------------
myapp            DefaultAppPool     http         C:\inetpub\wwwroot

PS IIS:\Sites\api.example.com> set-itemproperty myapp -name PhysicalPath -value D:\Projects\Demo

PS IIS:\Sites\api.example.com> get-itemproperty myapp

Name             Application pool   Protocols    Physical Path
----             ----------------   ---------    -------------
demo             DefaultAppPool     http         C:\inetpub\wwwroot

                                                 ^ THIS IS WRONG!

在Windows 7上运行完全相同的命令集,您将获得相同的输出,但是在最后一步,PhysicalPath属性已按预期进行了更改:

Running the exact same set of commands on Windows 7, you get identical output but at the last step the PhysicalPath property has changed as expected:

PS IIS:\Sites\api.example.com> get-itemproperty myapp

Name             Application pool   Protocols    Physical Path
----             ----------------   ---------    -------------
demo             DefaultAppPool     http         D:\Projects\Demo

知道发生了什么吗? IIS10是否有一些新的管理员限制?我需要某种类型的额外提升的权限来修改现有Web应用程序上的设置或其他内容吗?

Any idea what's going on? Is there some new admin restriction on IIS10? Some sort of extra elevated permissions I need to modify settings on existing web applications or something?

更新:如果该项目是IIS站点,则似乎工作正常,但如果该项目是Web应用程序,则失败,这使我怀疑这是否仅仅是提供程序中的错误.有什么想法吗?

UPDATE: It seems to work fine if the item is an IIS site, but fails if the item is a web application, which makes me wonder if this might just be a bug in the provider. Any ideas?

推荐答案

我不知道为什么,但是要设置的属性的首字母必须为小写. G. physicalPath

I don't know why but the first letter of the property you want to set must be lowercase e. g. physicalPath

这将起作用:

set-itemproperty myapp -name physicalPath -value D:\Projects\Demo

对我来说似乎是个错误,但是此表示法(首字母小写)也适用于您的其他Windows环境,因此应该是一个有效的解决方法.

Seems like a bug to me but this notation (first letter lowercase) also works for your other Windows environments thus should be a valid workaround.

这篇关于为什么Set-ItemProperty对Windows 10下的IIS应用程序不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆