[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 752
  • Last Modified:

Find and delete regitry settings

I am looking for a way to delete all entries in a particular registry location with the the word apple.

Thus far I have enabled the drive
$null = New-PSDrive -Name HKU   -PSProvider Registry -Root Registry::HKEY_USERS 

Open in new window


but I can't seem to figure out how to get a list of results based on a search.  

I want to delete all the key with the word apple out of
Get-Item -Path 'HKU:\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\Devices'

However filters don't work and I am at a bit of a loss.
0
brittonv
Asked:
brittonv
  • 5
  • 3
1 Solution
 
ScottyworldCommented:
Hi Brittony,

Try the following code, it will also recurse through the sub-keys too
 
Get-ChildItem -recurse 'HKU:\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\Devices' | Where-Object {$_.PSChildName -like '*apple*'} | remove-item -force

Open in new window

0
 
brittonvAuthor Commented:
It ran, but it didn't delete anything, and yes I am running Powershell as Administrator
0
 
brittonvAuthor Commented:
Also when I run:
Get-ChildItem -recurse 'HKU:\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\Devices'

The output is blank?  Even though I have a lot of things in there....
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
brittonvAuthor Commented:
Here is the output of a couple commands, I don't get why I am not getting results:

PS C:\> Get-ChildItem 'HKU:\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\'


    Hive: HKEY_USERS\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion


SKC  VC Name                           Property
---  -- ----                           --------
  0 234 Devices                        {Microsoft XPS Document Writer, Microsoft XPS Document Writer (from domain-110...
  0   0 EFS                            {}
  1   0 MsiCorruptedFileRecovery       {}
  0 235 PrinterPorts                   {Microsoft XPS Document Writer, Microsoft XPS Document Writer (from domain-110...
  0   1 SoftwareProtectionPlatform     {VLRenewalSchedule}
  0   2 Windows                        {UserSelectedDefault, Device}
  0   1 Winlogon                       {ExcludeProfileDirs}


PS C:\> Get-ChildItem 'HKU:\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\Devices'
PS C:\>

Open in new window

0
 
ScottyworldCommented:
OK, so are you looking for Keys or Values? (you said keys in your original question)

CurrentVersion and Devices are Keys
Everything in Devices is a String Value - is this where you are searching for 'apple" ?
0
 
brittonvAuthor Commented:
Yes, I am sorry!  I want to find apple in the string!
0
 
ScottyworldCommented:
Sorry, unfortunately my powershell knowledge doesn't extend that far.
The main problem is that the key's values are properties of the key, and hence seem to be harder to list.
I guess you would need to search (Google) for something around "changing registry key properties"

Using "Get-ItemProperty" in your query will list the properties for your key, but I haven't found a way to filter them
(I can probably do it in VBscript if thats any use though!)

0
 
brittonvAuthor Commented:
Thanks for trying
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now