mhamer
asked on
Powershell if exist
Hi can some one help with this.
need a script to check the registry and if a value exists carry on and run rest of script if reg entry doesnt exist error out
so sccm wont run if regentry isnt present
this is an edit of something that might work but it doesnt :-)
need a script to check the registry and if a value exists carry on and run rest of script if reg entry doesnt exist error out
so sccm wont run if regentry isnt present
this is an edit of something that might work but it doesnt :-)
if ((Test-Path "hklm:\Software\mch\$Manufacturer\$Product\$Ver") -eq $false)
{
$RegPath="hklm:\Software\mch\$Manufacturer\$Product\$Ver"
$reg=Get-Itemproperty $RegPath
if ($reg.Media_Reference -eq $installmediaid) {wegotaproblem "$Product is not installed"}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It was only really this bit that's troubling :)
(Test-Path TheRegKey) -eq $false
Because it's followed with "Get-Item TheRegKey" which only runs if the key doesn't exist which will break. A bit backwards you see.
Chris
ASKER
the code i posted was relying on other stuff elseware in script so it makes sense when you see the whole, but just breaking was fine for what i was needing thanks
ASKER