- <#
- .SYNOPSIS
- This script defines a function that sets autologon
- .DESCRIPTION
- Autologon enables the system to logon after a reboot without
- you needing to enter credentials. This is an ideal scenario
- for lab or training room systems. This script defines
- a function that sets a userid/password and autologon. It does NOT
- check to see if the value entries already exist.
- .NOTES
- File Name : Set-AutoAdminLogon
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> Set-AutoAdminLogon -user cookham\tfl -password 'JerryGarciaR0cks!'
- Auto logon set for [Cookham\tfl] with password: [JerryGarciaR0cks]
- #>
- Function Set-AdminLogon {
- [cmdletbinding()]
- Param(
- [string] $User = $(Throw 'No user id specified'),
- [string] $Password = $(Throw 'No password specified')
- )
- # Define registry path for autologon
- $RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
- # Set autologon
- New-ItemProperty -Path $RegPath -Name AutoAdminLogon -Value 1 -EA 0
- # Set userid and password
- New-ItemProperty -Path $RegPath -Name DefaultUserName -Value $User -EA 0
- New-ItemProperty -Path $regPath -Name DefaultPassword -Value $Password -EA 0
- # Say nice things and exit!
- Write-Host ("Auto logon set for [{0}] with password: [{1}]" -f $user, $password)
- }
- Set-AdminLogon -User 'Cookham\tfl' -Password 'JerryGarciaR0cks'
Technorati Tags: secuirty,admin logon
No comments:
Post a Comment