Created
July 25, 2017 19:06
-
-
Save xanthalas/612e1020f512c912cde156827b68ed81 to your computer and use it in GitHub Desktop.
Powershell script to enable/disable the Windows lock facility (Win+L)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param([Int32]$value=0) | |
| $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System" | |
| $Name = "DisableLockWorkstation" | |
| IF(!(Test-Path $registryPath)) | |
| { | |
| Write-Host "Cannot change the status as the key cannot be found" | |
| } | |
| ELSE | |
| { | |
| if ($value -ne 0 -and $value -ne 1) | |
| { | |
| Write-Host "Invalid parameter passed" | |
| } | |
| else | |
| { | |
| #The value is actually the reverse (which makes it counter-intuitive) so reverse it | |
| if ($value -eq 1) | |
| { | |
| $value = 0 | |
| } | |
| else | |
| { | |
| $value = 1 | |
| } | |
| Write-Host $value | |
| Write-Host $registryPath | |
| New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null | |
| if($value -eq 0) | |
| { | |
| Write-Host "Windows+L lock enabled" | |
| } | |
| else | |
| { | |
| Write-Host "Windows+L lock disabled" | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment