this is probably longer than it needs to be, and I stole most of it from Sean, 
and just made it be exactly what I *think* you meant.  Because there isn't a 
hklm/system/control/lsa, but there is a 
hklm/system/currentcontrolset/control/lsa, and a secureboot.  So I think this 
is what you meant... even if it's not what you said.   $branch = 
"HKLM:system\currentcontrolset\control\Lsa"$key = get-itemproperty -path 
$branch -Name 'SecureBoot'$value = ($key.SecureBoot)If ($value -eq 1) { 
Write-Host "the Key Secureboot already exists, and is a value of 1" 
}Else{New-ItemProperty -path $branch -name 'SecureBoot' -Value 1 -PropertyType 
DWORD -Force | Out-nullwrite-host "Created or Modified the key"} 
 

    On Thursday, September 8, 2016 9:29 AM, CESAR.ABREG0 . <elsal...@gmail.com> 
wrote:
 

 Kevin,  as Sean said, his 'sample script' is a pointer not a final product. 
You should be able to figure based on your requirements what's the next step. 
Help new-item -details 
On Thu, Sep 8, 2016, 6:58 AM Kevin Ray <kevinalive...@gmail.com> wrote:

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> 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









   


Reply via email to