Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to rename multiple registry entries at once.

$
0
0

Hi all, 

I just started trying to learn powershell and I thought I'll create a script to clean up office. 

For folders I managed to write the code:

Get-ChildItem -Path "C:\MSOCache\All Users" *0FF1CE*| Rename-Item -NewName {$_.Name + ".OLD"} -Force -ErrorAction 'silentlycontinue

However, this does not work with Registry where I need to search with wildcard? Correct me if I'm wrong.

$Path="HKLM:\SOFTWARE\Microsoft"
Get-Item -Path $Path\Windows\CurrentVersion\Uninstall\*TEST* | Rename-Item -NewName TEST.OLD -Force

Get-Item -Path $Path\Windows\CurrentVersion\Uninstall\*TEST*


    Hive: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall


SKC  VC Name                           Property                                                                                                                                        
---  -- ----                           --------                                                                                                                                        
  0   0 xxxTESTzzz                     {}                                                                                                                                              
  0   0 zzzTESTzzz                     {}            

So the Reg  keys are being found. If I run the code as above, it only changes one of the two.

I also tried exactly as per Office folder. 

$Path="HKLM:\SOFTWARE\Microsoft"
Get-Item -Path $Path\Windows\CurrentVersion\Uninstall\*TEST* | Rename-Item -NewName {$_.Name + ".OLD"} -Force

It just says that the key at the specified path does not exist. I assume that when I run the ps it searches for *TEST* folder and not for keys containing TEST in name. 

What I want to achieve is exactly as per MSOCache, renaming xxxTESTxxx to xxxTESTxxx.OLD and zzzTESTzzz to zzzTESTzzz.OLD

Greatly appreciating your help, also if possible with explanation.

Thanks!


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>