Add registry DWORD value

02/11/2012 09:50

#you can go to the psdrive directly, but don't need

set-location hklm: #for HKEY_LOCAL_MACHINE

 

#go to the lsa registry
Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

#get item from registry if exists
$p=Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa -Name DisableLoopbackC -ea 0

#if doesn't exist, create new
if($p -eq $null)
{
    New-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\" -Name "DisableLoopBackCheck" -Value 1 -PropertyType "DWord"
}

#Remove Item from registry
Remove-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\ -Name LukasPokus