Searching the registry in PowerShell for a specific string value is very easy. Just change the value of $SearchString to reflect the string value you are searching the local registry for.
<#
===========================================================
Script Name: SearchReg.ps1
Author: Jason A. Yoder, MCT
Website: www.MCTExpert.com
Blog: www.MCTExpert.Blogspot.com
===========================================================
===========================================================
Script Purpose:
Searches the local registry for a specified string value.
===========================================================
===========================================================
Requirements:
PowerShell V2
===========================================================
#>
# ===========================================================
# Global Varibles
# == End of Global Variables ================================
#Enter the string value to search for in the variable below.
$SearchString = "Testing"
# ===========================================================
# Functions
# == End of Functions =======================================
# ===========================================================
# Main Code:
# Write a message to the user to let them know the scrip
# has started.
Write-Host "Searching: HKCU" -ForegroundColor White `
-BackgroundColor DarkBlue
# Search the registery for the string value. Display the
# registry key each time the value is located.
Get-ChildItem HKCU:\ -Recurse -ErrorAction SilentlyContinue |
ForEach-Object {
if((get-itemproperty -Path $_.PsPath) -match $searchString)
{
$_.PsPath
}
}
# Write a message to let the user know the script completed.
Write-Host "SearchReg.ps1 has completed." -ForegroundColor Yellow `
-BackgroundColor DarkBlue
# == End of Main Code =======================================
<#
===========================================================
Script Name: SearchReg.ps1
Author: Jason A. Yoder, MCT
Website: www.MCTExpert.com
Blog: www.MCTExpert.Blogspot.com
===========================================================
===========================================================
Script Purpose:
Searches the local registry for a specified string value.
===========================================================
===========================================================
Requirements:
PowerShell V2
===========================================================
#>
# ===========================================================
# Global Varibles
# == End of Global Variables ================================
#Enter the string value to search for in the variable below.
$SearchString = "Testing"
# ===========================================================
# Functions
# == End of Functions =======================================
# ===========================================================
# Main Code:
# Write a message to the user to let them know the scrip
# has started.
Write-Host "Searching: HKCU" -ForegroundColor White `
-BackgroundColor DarkBlue
# Search the registery for the string value. Display the
# registry key each time the value is located.
Get-ChildItem HKCU:\ -Recurse -ErrorAction SilentlyContinue |
ForEach-Object {
if((get-itemproperty -Path $_.PsPath) -match $searchString)
{
$_.PsPath
}
}
# Write a message to let the user know the script completed.
Write-Host "SearchReg.ps1 has completed." -ForegroundColor Yellow `
-BackgroundColor DarkBlue
# == End of Main Code =======================================
Comments