Member_2_8171182
asked on
PowerShell Delete Value From Registry With String In File-Name
I have A PowerShell Script that will delete Key with string in name.
I need help with A script that will delete Value with string in name
This will delete by string in folder name from registry.
I have use this to delete string in file-name.
Thanks in advanced.
I need help with A script that will delete Value with string in name
This will delete by string in folder name from registry.
# Folders (Key)
Get-ChildItem -Path HKLM:\ -Recurse -Include *String* -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse -confirm:$false -Whatif
I have use this to delete string in file-name.
cd $env:SystemRoot
$string = "String"
get-childitem -recurse| where-object {$_.Name -like "*$string*"} | foreach ($_) {remove-item $_.fullname -recurse -confirm:$false}
Thanks in advanced.
ASKER
Are you asking to delete any registry value where its name matches (even partially) a particular string?
Yes Actually, Values or Data. The first script will delete keys containing string from the registry. (Apologies for my ignorance.)
The second script is for file and directories containing string in file name.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many Thanks! A quick follow up question,
Can the
Can the
-ErrorAction SilentlyContinueparameter be used?
Simple answer is, "yes", but it's a pretty vague question.
Where would you put it and what are you hoping to achieve?
Where would you put it and what are you hoping to achieve?
ASKER
Similar to the first script, to ignore all errors.
Sure, it won't pose any problem.
We've got registry keys, which are shown in the left pane in regedit; and we've got registry values, which are shown in the right pane in regedit. Registry values have a name, type, and data.
Are you asking to delete any registry value where its name matches (even partially) a particular string?
*Item cmdlets are used to work with with keys (though output formatting from the Get-Item and Get-ChildItem cmdlets shows some info about values as well, since PS 3.0+), while *-ItemProperty cmdlets are used with values.