u/Electrical_Staff8168

Good afternoon,

I'm trying to run a check against some Registry entry values to ensure they're present, and correct. I was able to get a script to tell me if the keys were present, now I'm having trouble checking the values. The first value returns, and checks against it's expected value just fine. The second value, returns a mismatch, but running the Get-ItemPropertyValue on it's own returns a string that matches my second expected value.

If I run:

`#Is PC_CLIENT_PATH Value Correct?`

	`$RegItem = @{`

		`Path = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Vendor\Popup'`

		`Name1 = 'PC_CLIENT_PATH'`

		`val1 = 'C:\Program Files (x86)\Vendor\client.exe'`

		`Name2 = 'SECRET_FILE_PATH'`

		`val2 = 'C:\Program Files (x86)\Vendor\pc-shared-secret.dat'`



	`}`





`# Check to see if PC_CLIENT_PATH Value is present.`

	`$val1check = Get-ItemPropertyValue -Path $RegItem.Path -Name $Regitem.Name1 -ErrorAction SilentlyContinue`

		`if ($val1check -eq $val1) {Write-Host 'HKLM:PC_CLIENT_PATH Value is correct' -f green}`

		`else {Write-Host 'HKLM:PC_CLIENT_PATH Value is incorrect' -f red}`





`# Check to see if SECTRET_FILE_PATH Value is present.`

	`$val2check = Get-ItemPropertyValue -Path $RegItem.Path -Name $Regitem.Name2 -ErrorAction SilentlyContinue`

		`if ($val2check -eq $val2) {Write-Host 'HKLM:SECRET_FILE_PATH Value is correct' -f green}`

		`else {Write-Host 'HKLM:SECRET_FILE_PATH Value is incorrect' -f red}`

I get the following results:

HKLM:PC_CLIENT_PATH Value is correct

HKLM:SECRET_FILE_PATH Value is incorrect

But if I run:

Get-ItemPropertyValue -Path $RegItem.Path -Name $Regitem.Name2 -ErrorAction SilentlyContinue

I get back:

C:\Program Files (x86)\Vendor\pc-shared-secret.dat

So, What gives? Why isn't that second value being verified correctly? Any help is appreciated. I hope I formatted this correctly.

reddit.com
u/Electrical_Staff8168 — 7 days ago