Find a subkey in the registry key data and subkeys then change the subkey’s value.
This is how it was presented to me:
I am trying to find 2 registry values I don’t have exact path it could be anywhere in sub registry. Is there search options in PowerShell it could look entire sub registry. Find it and replace it with new value? I tried to use (*) it didn’t find anything.
Not a problem.
#Find a key in registry and change it's value. Get-Item -ErrorAction SilentlyContinue -path "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System\Test" | foreach { Get-ItemProperty -Path "Microsoft.PowerShell.Core\Registry::$_" | foreach { $CurrentUserShellFoldersPath = $_.PSPath $_.PSObject.Properties | foreach { if ($_.Value -like "10.0.0.5") { write-host "Name:`t`t"$_.Name write-host "Old Value:`t"$_.Value $newValue = $_.Value $newValue = $newValue -replace '10.0.0.5', "10.0.0.6" Set-ItemProperty -Path $CurrentUserShellFoldersPath -Name $_.Name -Value $newValue } } } }
Checkout our post on Using DcDiag For Active Directory Diagnostics