Hi
How can I use the “Test-RegistryValue” to check the version of value data?
HKEY_LOCAL_MACHINE\SOFTWARE\XXXX
values = version
value data= 1.2
I need to compare the value date.
doron
Hi
How can I use the “Test-RegistryValue” to check the version of value data?
HKEY_LOCAL_MACHINE\SOFTWARE\XXXX
values = version
value data= 1.2
I need to compare the value date.
doron
Try this:
Test-RegistryValue -Key 'HKEY_LOCAL_MACHINE\SOFTWARE\XXXX' -Value 'value data'
If not, then try this:
Test-RegistryValue -Key 'HKLM:SOFTWARE\XXXX' -Value 'value data'
I wouldn’t use PSADT’s Test-RegistryPath for this. I’d use PowerShell’s built-in cmdlets. Something like the following. Obviously, you’d need to edit the variables to suit your scenario. The Path and Name below are from a script I recently wrote to disable missing PCs.
$RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\'
$RegName = 'CachedLogonsCount'
$RegValue = $null
If (Test-Path -Path $RegPath)
{
$RegValue = (Get-ItemProperty -Path $RegPath).$RegName
}
Else
{
Write-Log 'The Registry path does not exist.'
}
Now that $RegValue contains the current value, you’d use an If
or Switch
to process the result.
If ($RegValue -eq 0)
{
Set-Fire -To "$Computer"
}
Else
{
Send-Flowers -To $User
}
-OR-
Switch ($RegValue)
{
"0"
{Set-Fire -To "$Computer"}
"1"
{Send-Flowers -To "$User"}
}