删除注册表值的父键 [英] Deleting a Registry value's Parent Key

查看:62
本文介绍了删除注册表值的父键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在升级到新的无线系统,因此我们正在通过 GPO 推出 SSID.但是,我们想从系统中删除现有的 SSID/配置文件,这不是简单使用netsh wlan delete profile name"的问题.我们遇到的问题是从我们用户的Lenovo Access Connections"中删除这些配置文件,它管理着大多数(如果不是全部)用户的各种网络配置文件.如果使用 netsh 删除它,用户只需打开 Access Connections,它就会在 Windows 中重新创建该配置文件.我们不能简单地删除配置文件,因为每个用户都可以在程序中使用他们想要的任何昵称命名我们的公司网络.话虽如此,我已经找到了这些配置文件在注册表中的存储位置.

We’re currently upgrading to a new Wireless system and with that we’re pushing out the SSID through a GPO. However, we would like to remove the existing SSID/Profile from the system, which isn’t an issue with simply using "netsh wlan delete profile name". The problem we’re having is removing these profiles from our user’s "Lenovo Access Connections" which is managing most (if not all) user’s various network profiles. If it’s deleted with the netsh, the user can simply open up Access Connections and it will recreate that profile within Windows. We cannot simply delete the profiles since each user can name our company network with whatever nickname they want within the program. That being said, I’ve found where these profiles are stored within the registry.

联想接入连接:

HKLM\SOFTWARE\Wow6432Node\Lenovo\Access Connections\Locations

这就是问题所在,我想不出在Locations文件夹中搜索我们的SSID的方法,然后删除它的主键.目前布局如下:

This is where the problem lies, I cannot figure a means to search within the Locations folder for our SSID, then delete it’s main key. It is currently laid out like this:

\Locations\(Custom Profile Name)\AdptList\Adpt00\

Adpt00 密钥中有一个 Reg_SZ,名称为 m_szSsid,其值 = Our Network的 SSID.所以,基本上我想搜索所有 \Locations 以及 Adpt00 键中的任何 m_szSsid 是否为每个不同的配置文件存在.. 从 \Locations 中删除整个配置文件,是的,我们的一些用户由于我不知道的原因为同一个网络 SSID 设置了多个配置文件.

Within the Adpt00 Key there is a Reg_SZ with the name of m_szSsid with it’s value = Our Network’s SSID. So, basically I’m looking to search ALL of \Locations and if any of the m_szSsid within the Adpt00 Key for each of the varying Profiles exists.. delete the entire Profile from \Locations, and yes some of our user’s have multiple Profile’s setup for the same Network SSID for a reason unknown to me.

这是我目前所拥有的

$LACKey = "HKLM:\SOFTWARE\Wow6432Node\Lenovo\Access Connections\Locations"
$LACProfileKey = Get-ChildItem $LACKey -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
   If((Get-ItemProperty -Path $_.PsPath) -match "m_szSsid")
      {
      $_.PsPath
      }
  }

这将返回当前测试机器的 \Locations 下唯一的配置文件(仅包含一个匹配的配置文件),但从这里我不确定如何扩展 m_szSsid 用于找到每个匹配的无线配置文件,以确保它与我们的 SSID 匹配.然后从那里删除 \Locations\

This returns the only profile under \Locations for the current test machine (which only contains one matching profile), but from here I'm unsure of how to expand the m_szSsid for each matching Wireless Profile found to ensure it matches our SSID. Then from there Delete the Parent profile folder under \Locations\

我做了一些改变

$LACKey = 'SOFTWARE\Wow6432Node\Lenovo\Access Connections\Locations'
$LACProfileKey = Get-ChildItem "HKLM:\$LACKey" -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
If(( Get-ItemProperty -Path $_.PsPath) -match "m_szSsid") {
$_.PsPath 
ForEach-Object {
If((Get-ItemProperty -Path $LACProfileKey -Name m_szSsid).m_szSsid -match "<Company SSID HERE>") {
$ssIDKey = (Get-ItemProperty -Path $LACProfileKey $_.PSParentPath).PSParentPath
}
}
}
}

但是我返回了这个错误

Get-ItemProperty : Property Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Lenovo\Access C
onnections\Locations\<Company SSID HERE>\AdptList does not exist at path HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Lenovo\Access Con
nections\Locations\HYDAC-NA\AdptList\Adpt00.
At line:6 char:29
+ $ssIDKey = (Get-ItemProperty <<<<  -Path $LACProfileKey $_.PSParentPath).PSParentPath
+ CategoryInfo          : InvalidArgument: (Microsoft.Power...ID ERE>\AdptList:String)   [Get-ItemProperty], PSArgume
   ntException
   + FullyQualifiedErrorId :    System.Management.Automation.PSArgumentException,Microsoft.PowerShell.Commands.GetItemPr
  opertyCommand

我将不胜感激任何进一步的指导,我确信很明显我是一个 Powershell 新手 ;)

I would appreciate any further guidance on this,I'm sure it is obvious I am quite a Powershell Novice ;)

推荐答案

您是否尝试过:

Get-ItemProperty -Path $_.PSPath -Name "m_szSsid" 

您还有 $_.PSPath$_.PSParentPath,有了这些信息,您应该可以使用 Remove-Item 在适当的注册码上

You also have $_.PSPath and also $_.PSParentPath, with this information, you should be able to use Remove-Item on the appropriate regkey

这篇关于删除注册表值的父键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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