Hello All,
I am trying to enumerate a registry key property value in an If Else statement with the following code but the enumeration does not seem to work for the conditions to be effective:
<code>
$RegistryKey = "hkcu:\software\microsoft\windows\currentversion\explorer\Advanced" #This is the registry path. Please replace the example registry path between the quotes.
$RegistryKeyProperty = "HideFileExt" #This is the registry key property whose value will be remediated if needed. Please replace the property between the quotes.
$RegistryKeyPropertyValue = Get-ItemProperty -Path $RegistryKey -Name $RegistryKeyProperty #This is the value to be remediated if needed. Please replace the example value between the quotes.
$Compliance = "" #The $Compliance variable is set to 'NonCompliant' by default.
#Set-Location $RegistryKey #Navigate to the registry path.
If ($RegistryKeyPropertyValue -eq 0) #Discovery for the registry key property value.
{
$Compliance = "Compliant" #If the discovery check above passes, set the $Compliance variable to 'Compliant'.
Write-Output $Compliance #And output the value of the $Compliance variable for access by SCCM.
}
else
{
Write-Output $Compliance #Otherwise, if the discovery check above fails, set the value of the $Compliance variable to 'NonCompliant' for access by SCCM.
}
</code>
Any idea on how to accomplish this would be great.
Thanks
- Edited by techiegzz Saturday, February 07, 2015 4:51 PM