为什么Get-ItemProperty不区分大小写,但Set-ItemProperty区分大小写? [英] Why Get-ItemProperty is case insensitive but Set-ItemProperty is case sensitive?

查看:626
本文介绍了为什么Get-ItemProperty不区分大小写,但Set-ItemProperty区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过 PowerShell DefaultAppPool 设置 IIS 属性c $ c>我最后得到一个非常好奇的案例:

I was trying to set IIS properties for my DefaultAppPool via PowerShell and I end up with a really curious case:


  • Get-ItemProperty不区分大小写。

  • Set-ItemProperty区分大小写。

有人知道我们为什么会有这种奇怪的行为吗?

Does someone know why we have this curious behaviour?

PS C:\Windows\system32> Import-Module WebAdministration    
PS C:\Windows\system32> Get-ItemProperty -Path "IIS:\AppPools\DefaultAppPool" -Name Recycling.periodicRestart.privateMemory

...
Value                       : 27

PS C:\Windows\system32> Set-ItemProperty -Path "IIS:\AppPools\DefaultAppPool" -Name Recycling.periodicRestart.privateMemory -Value 10

PS C:\Windows\system32> Get-ItemProperty -Path "IIS:\AppPools\DefaultAppPool" -Name Recycling.periodicRestart.PrIVATeMemory

...
Value                       : 10

PS C:\Windows\system32> Set-ItemProperty -Path "IIS:\AppPools\DefaultAppPool" -Name Recycling.periodicRestart.PRIvateMemory -Value 15

PS C:\Windows\system32> Get-ItemProperty -Path "IIS:\AppPools\DefaultAppPool" -Name Recycling.periodicRestart.PrivateMemory

...
Value                       : 10 #should be 15 if case insensitive...


推荐答案

POSH中的获取语句用于数据收集和对象构建/逻辑编排。换句话说,GetX命令永远不会改变具有区分大小写的服务的配置文件(所有的管理单元都在那里,谁知道哪些服务具有POSH抽象)。 Set命令几乎可以全面用于改变运行它们的系统或系统的配置(或使用WMI / WinRM远程)。

"Get" statements in POSH are for data gathering and object building/logic orchestration. In other words, a "Get" X command is never going to alter a configuration file that has a service counting on case sensitivity (with all the snap-ins out there, who knows what service has a POSH abstraction). "Set" commands are almost holistically used to alter the system or configuration of the system they are run on (or remote with WMI/WinRM).

这篇关于为什么Get-ItemProperty不区分大小写,但Set-ItemProperty区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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