How to test a registry key in PowerShell

By , 31 august, 2008 23:25

In PowerShell you easley can test a registry key with the cmdlet Get-ItemProperty.

PS C:\> $key = $(Get-ItemProperty «HKLM:\SOFTWARE\LJS»).LarsJostein -eq «Silihagen»
PS C:\> $key
True

PowerShell example where  you test the installed Operations Manager Console version:
function OpsMgrVer
{
return $ver = $(Get-ItemProperty «HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup»).CurrentVersion
}
function TestVersion
{
$nr = OpsMgrVer
if (OpsMgrVer -ge «6.0.6270.0″)
{ Write-Host «SCOM 2007 SP1 is installed. ServerVersion: $nr» } else { Write-Host «SCOM 2007 SP1 is not installed. ServerVersion: $nr» }
}

Post to Twitter Post to Facebook Post to LinkedIn

Panorama Theme by Themocracy