如何使用PowerShell获取键内注册表值的数据值
发布时间:2020-12-14 05:38:57 所属栏目:Windows 来源:网络整理
导读:在我的函数中,我想在特定子项的数据部分中搜索特定字符串.函数内部的一部分代码如下: foreach ($CurrentPath in $Path) { $Items = Get-Item -Path Registry::$CurrentPath ForEach ( $Property in $Items) { $Key = $Property 当我在$Key = $Property之后
在我的函数中,我想在特定子项的数据部分中搜索特定字符串.函数内部的一部分代码如下:
foreach ($CurrentPath in $Path) { $Items = Get-Item -Path Registry::$CurrentPath ForEach ( $Property in $Items) { $Key = $Property 当我在$Key = $Property之后直接调试并转到主机命令窗口并输入$Key并按Enter键.它返回: Hive: hkcu Name Property ---- -------- ABC Test : abababMSSQLSERVER_2014ababab 我希望我的功能还可以搜索数据部分,如附在图像中所示,这是在regedit中. 我如何完成搜索? 解决方法
如果您不知道值名称,则需要循环属性.使用Get-Item的示例:
$item = Get-Item -Path "Registry::HKEY_CURRENT_USERSoftwareNuGet" foreach ($prop in $item.Property) { if($item.GetValue($prop) -match '0') { "Match found in key $($item.PSPath),value $($prop)" } } 或者Get-ItemProperty: $item = Get-ItemProperty -Path "Registry::HKEY_CURRENT_USERSoftwareNuGet" foreach ($prop in $item.psobject.Properties) { if($prop.Value -match '0') { "Match found in key $($item.PSPath),value $($prop.Name)" } } 如果您知道value-name,那么使用Get-ItemProperty和Where-Object更容易,例如: Get-ItemProperty -Path "Registry::HKEY_CURRENT_USERSoftwareNuGet" | Where-Object { $_.IncludePrerelease -match '0' } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-server-2008 – 为什么我不能在外部访问Tomcat?
- windows-server-2008-r2 – Windows任务计划程序在下次运行
- 没有更多适用于Windows的SVN控制台客户端?
- iis – 如何衡量支持TLS 1.2的访问者的细分?
- AVX2字节用uint16索引收集到__m256i中
- .net – Windows XP和7之间发生了什么变化,导致我的Mono C#
- Windows 7:过冲C std :: this_thread :: sleep_for
- windows-server-2008 – 在多台Windows机器上安装CA证书(IE
- Windows中的计时器
- Windows – 在Workstation上重新安装ADCS CA证书和CRL