Sunday, 2 December 2012

Remove-AdminLogon.ps1

  1. <#
  2. .SYNOPSIS
  3. This script defines a function that removes autologon
  4. .DESCRIPTION
  5. Autologon enables the system to logon after a reboot without
  6. you needing to enter credentials. This is an ideal scenario
  7. for lab or training room systems. This script defines
  8. a function that removes the autologon registry keys
  9. .NOTES
  10. File Name : Remove-AdminLogon
  11. Author : Thomas Lee - tfl@psp.co.uk
  12. Requires : PowerShell Version 2.0
  13. .LINK
  14. This script posted to:
  15. http://www.pshscripts.blogspot.com
  16. .EXAMPLE
  17. Psh> Remove-AdminLogon
  18. Auto logon settings removed
  19. #>
  20. Function Remove-AdminLogon {
  21. [Cmdletbinding()]
  22. Param()
  23. # Define registry path for autologon
  24. $RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
  25. # Remove autologon property
  26. Remove-ItemProperty -Path $RegPath -Name AutoAdminLogon
  27. # Remove userid and password
  28. Remove-ItemProperty -Path $RegPath -Name DefaultUserName
  29. Remove-ItemProperty -Path $RegPath -Name DefaultPassword
  30. # Say nice things and exit!
  31. Write-Host ("Auto logon removed")
  32. }
  33. Remove-AdminLogon
Technorati Tags: ,

No comments: