Hi Sean ...its not working..its creating the new key My requirement is
Under registry hklm\system\control\Lsa Need to check the name secureboot=1 If the value is different than 1 it should reset to 1 also if the name "secureboot" is not present it should create it with value 1..... On Wednesday, September 7, 2016, Sean Martin <seanmarti...@gmail.com> wrote: > Not able to test, but hopefully this points you in the right direction: > > $key = "HKLM\System\Test" > $Name = (Get-ItemProperty -Path $key -Name hai).hai > $Valuename = "hai" > $Value = "8" > > If (Test-Path $key) { > Write-Host "Registry Path $key exists" > If (!($Name) { > New-ItemProperty -path $key -name $Name -Value $value -PropertyType > DWORD -Force | Out-null > Write-Host "Registry Value for $key\$Name created and updated to $Value" > } Elseif ($Name) { > If ($Name -ne "8") { > New-ItemProperty -path $key -name $Name -Value $value -PropertyType > DWORD -Force | Out-null > Write-Host "Registry Value for $key\$Name updated to $Value" > } Elseif ($Name -eq "8") { > Write-Host "Registry value for $key\$name already set to $Value" > } > } > } Elseif (!(Test-Path $key) { > New-Item -Path $key -Force | Out-Null > Write-Host "Registry path $key created successfully" > New-ItemProperty -path $key -name $ValueName -Value $Value -PropertyType > DWORD -Force | Out-null > Write-Host "Registry value $key\$ValueName created successfully and set > to $Value" > } > > > > > > On Wed, Sep 7, 2016 at 6:53 AM, Kevin Ray <kevinalive...@gmail.com > <javascript:_e(%7B%7D,'cvml','kevinalive...@gmail.com');>> wrote: > >> Hi All, >> >> Im looking for path in registry " hklm\system\test" >> >> Then if test exist, then -name = hai >> >> If name exist then value should be 8...if value is other than 8 it should >> set to 8 and if the name "hai"...not exist also it should created " hai" >> with value 8......any help >> >> > >