Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. param([Int32]$value=0)
  2. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System"
  3. $Name = "DisableLockWorkstation"
  4.  
  5. IF(!(Test-Path $registryPath))
  6. {
  7. Write-Host "Cannot change the status as the key cannot be found"
  8. }
  9. ELSE
  10. {
  11. if ($value -ne 0 -and $value -ne 1)
  12. {
  13. Write-Host "Invalid parameter passed"
  14. }
  15. else
  16. {
  17. #The value is actually the reverse (which makes it counter-intuitive) so reverse it
  18. if ($value -eq 1)
  19. {
  20. $value = 0
  21. }
  22. else
  23. {
  24. $value = 1
  25. }
  26. Write-Host $value
  27. Write-Host $registryPath
  28. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  29. if($value -eq 0)
  30. {
  31. Write-Host "Windows+L lock enabled"
  32. }
  33. else
  34. {
  35. Write-Host "Windows+L lock disabled"
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement