How to read multi line multi string registry entries in PowerShell?

为君一笑 提交于 2019-12-10 21:08:13

问题


I am trying to read the "-Dhttp.port" value with no luck.

AS you can see in the attached image, "Options" is a sub-key and I am able to read "Options" using the following snippet (this shows unnecessary PowerShell items too though)

Get-ItemProperty $PATH -Name "Options"    

Now from the multi-line "Options" I want to read the value of specific sub-key "-Dhttp.port" which is 80 here

Output for Get-ItemProperty $PATH -Name "Options" is

I want to read only "Options", and from Options key I want to read value of "-Dhttp.port".


回答1:


PS>( Get-ItemProperty $PATH |select -ExpandProperty Options|where {$_ -match "-Dhttp.port"}).split("=")[1]


来源:https://stackoverflow.com/questions/14139000/how-to-read-multi-line-multi-string-registry-entries-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!