![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Finding and removing values in registry subkeys I have been directed by Microsoft CSS to follow the instructions in KB300956 "How to manually rebuild Performance Counter Library values" on a Windows SBS 2003 server. In that KB article, it states to search within HKLM:\SYSTEM\CurrentControlSet\Services for services that have a Performance subkey and then to remove the following values from the Performance subkey if they exist: - First Counter - First Help - Last Counter - Last Help I initially attempted to do this manually and found myself still clearing this from services that started with "D" after an hour's worth of effort. So, I have been trying to put together a PowerShell script that will do it. I know that I can Set-Location to HKLM:\SYSTEM\CurrentControlSet\Services and then I can Get-ChildItem .\*\Performance and see all of the services that have a Performance subkey. So, I have something to send down the pipeline. I just can't figure out how to do the rest. I know that I would use Remove-ItemProperty to delete the registry values. I have found the Search-Registry.ps1 script in Lee's book. I just can't figure out how to make all of the pieces work. Thank you for any help. |
| | #2 (permalink) | ||||||||||||
| Guest | Re: Finding and removing values in registry subkeys Michael Pope wrote:
Get-ChildItem .\*\Performance|Foreach-Object{ get-itemproperty -path $_.pspath -name "last counter" } So you'd use remove-itemproperty, instead of get-itemproperty. I'm not checking for the value though, so you may get lots of errors, I'm just assuming it is there, and if it is, I'm getting it above. To check for all four: Get-ChildItem .\*\Performance|Foreach-Object{ get-itemproperty -path $_.pspath -name "last counter" get-itemproperty -path $_.pspath -name "last help" get-itemproperty -path $_.pspath -name "first counter" get-itemproperty -path $_.pspath -name "first help" } ***Use at your own risk*** ***Use at your own risk*** ***Use at your own risk*** ***Use at your own risk*** Please do a complete backup before running such a widespread delete... Doing this will remove any error messages if the value is not found: .... get-itemproperty -path $_.pspath -name "first counter" -erroraction silentlycontinue .... Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Finding and removing values in registry subkeys Perfect, Marco. I did a backup of the Services key and then I ran it with a transcript enabled and the -WhatIf option enabled on all of the Remove-ItemProperty commands and it did what I thought it would do. So, I removed that option and ran it for real and it was done in less than five seconds! Thank you so much for your help. I am finding more and more real-world uses for PowerShell. Michael "Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message news:%23lNnpGghIHA.5160@xxxxxx
| ||||||||||||||||||||||||
| | #4 (permalink) | ||||||||||||
| Guest | Re: Finding and removing values in registry subkeys Michael Pope wrote:
This is a good example of time-savings provided with PowerShell. I'll blog about it, and your final solution which is very good/complete for being able to review all the changes before actually running them. Marco | ||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| enumerate registry subkeys | knothead | VB Script | 3 | 1 Week Ago 12:56 PM |
| My documents messed up, need help finding registry values!! | Respawns | Vista file management | 3 | 05-15-2008 02:49 AM |
| Cannot delete a registry key (or subkeys) --- ??? | notaguru | Vista General | 10 | 10-29-2007 07:49 PM |
| need some registry values | Michael | Vista General | 5 | 03-12-2007 11:01 PM |
| Info: I need to compare Registry Subkeys between a Model Server and a Server | Brandon Shell | PowerShell | 3 | 08-27-2006 04:25 PM |