I need to look in Windows registry and get a specific value out of a list of subkeys. What I want is to have a return output as "ok" only when all values properties in these subkeys are equal to "2".
If I write something like this:
$regkey = "HKLM:SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces"
Get-ChildItem $regkey |
foreach { $NetbiosOptions_Value = (Get-ItemProperty "$regkey\$($_.pschildname)").NetbiosOptions }
if ($NetbiosOptions_Value -eq 2) {
write-output "ok"}
else{
}
obviously gives me "OK" with just one of the values being equal to "2" but what I want is to have "OK" only when all values are equals to "2"
Thanks
Aucun commentaire:
Enregistrer un commentaire