您现在的位置是:网站首页> 编程资料编程资料
PowerShell小技巧之查找获取注册表路径_PowerShell_
2023-05-26
396人已围观
简介 PowerShell小技巧之查找获取注册表路径_PowerShell_
在先前的技巧中我们说明如何将一个PS内置的路径格式转化成一个实际路径。这里介绍了一个例子。这段代码递归从HKEY_CURRENT_USER获取所有包含”powershell”词缀的键(简单的替换查询词缀将能获得你想要查询的任何东西)
复制代码 代码如下:
Get-ChildItem -Path HKCU:\ -Include *PowerShell* -Recurse -ErrorAction SilentlyContinue|Select-Object -Property *Path* | Out-GridView
这段代码输出了所有包涵“路径”的属性,同时你将看到,注册表中有两个属性包含关键字:PSpath和PSParentPath都使用PS内置的路径格式。
要简单的取出注册表中的路径来满足你的查询标准,你这样尝试:
复制代码 代码如下:
Get-ChildItem -Path HKCU:\ -Include *PowerShell* -Recurse -ErrorAction SilentlyContinue|ForEach-Object { Convert-Path -Path $_.PSPath }
支持所有PS版本
您可能感兴趣的文章:
相关内容
- PowerShell小技巧之True和False的类型转换_PowerShell_
- PowerShell小技巧之观察UNC路径_PowerShell_
- PowerShell小技巧之使用Verb打开程序_PowerShell_
- PowerShell小技巧之从函数中返回多个值_PowerShell_
- PowerShell小技巧之使用New-Module命令动态创建对象_PowerShell_
- PowerShell小技巧之使用Hotmail账号发送邮件_PowerShell_
- Powershell小技巧之设置IE代理_PowerShell_
- Powershell小技巧之找出最大最小值_PowerShell_
- Powershell小技巧之屏蔽输出结果_PowerShell_
- Powershell小技巧之删除不规则字符_PowerShell_
