Showing posts with label security. Show all posts
Showing posts with label security. Show all posts

Sunday, 2 December 2012

Set-AdminLogon.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script defines a function that sets 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 sets a userid/password and autologon.
  9. .NOTES 
  10.     File Name  : Set-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> New-AdminLogon -user cookham\tfl -password 'JerryGarciaR0cks!' 
  18.     Auto logon created for [Cookham\tfl] with password: [JerryGarciaR0cks]          
  19.  
  20. #> 
  21.  
  22. Function New-AdminLogon { 
  23.  
  24. [cmdletbinding()] 
  25. Param( 
  26. [string] $User     = $(Throw 'No user id specified'), 
  27. [string] $Password = $(Throw 'No password specified'
  28.  
  29. # Define registry path for autologon 
  30. $RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' 
  31.  
  32. # Set autologon 
  33. Set-ItemProperty -Path $RegPath -Name AutoAdminLogon -Value 1  
  34.  
  35. # Set userid and password 
  36. Set-ItemProperty -Path $RegPath -Name DefaultUserName -Value $User  
  37. Set-ItemProperty -Path $regPath -Name DefaultPassword -Value $Password  
  38.  
  39. # Say nice things and exit! 
  40. Write-Host ("Auto logon [{0}] set to password: [{1}]" -f $user, $password
  41.  
  42. Set-AdminLogon -User 'Cookham\tfl' -Password 'JerryGarciaR0cks' 
Technorati Tags: ,

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: ,

New-AutoAdminLogon.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script defines a function that sets 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 sets a userid/password and autologon. It does NOT 
  9.     check to see if the value entries already exist. 
  10. .NOTES 
  11.     File Name  : Set-AutoAdminLogon 
  12.     Author     : Thomas Lee - tfl@psp.co.uk 
  13.     Requires   : PowerShell Version 2.0 
  14. .LINK 
  15.     This script posted to: 
  16.         http://www.pshscripts.blogspot.com 
  17. .EXAMPLE 
  18.     Psh> Set-AutoAdminLogon -user cookham\tfl -password 'JerryGarciaR0cks!' 
  19.     Auto logon set for [Cookham\tfl] with password: [JerryGarciaR0cks]          
  20.  
  21. #> 
  22.  
  23. Function Set-AdminLogon { 
  24.  
  25. [cmdletbinding()] 
  26. Param( 
  27. [string] $User     = $(Throw 'No user id specified'), 
  28. [string] $Password = $(Throw 'No password specified'
  29.  
  30. # Define registry path for autologon 
  31. $RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' 
  32.  
  33. # Set autologon 
  34. New-ItemProperty -Path $RegPath -Name AutoAdminLogon -Value 1 -EA 0 
  35.  
  36. # Set userid and password 
  37. New-ItemProperty -Path $RegPath -Name DefaultUserName -Value $User -EA 0 
  38. New-ItemProperty -Path $regPath -Name DefaultPassword -Value $Password -EA 0 
  39.  
  40. # Say nice things and exit! 
  41. Write-Host ("Auto logon set for [{0}] with password: [{1}]" -f $user, $password
  42.  
  43. Set-AdminLogon -User 'Cookham\tfl' -Password 'JerryGarciaR0cks' 
Technorati Tags: ,

Tuesday, 29 March 2011

New-Credential.ps1

  1. <# 
  2. .SYNOPSIS 
  3.    A function to create a credential object from script. 
  4. .DESCRIPTION 
  5.    Enables you to create a credential objects from stored details. 
  6. .NOTES 
  7.     File Name  : New-Credential.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell Version 2.0 
  10. .LINK 
  11.     This script posted to: 
  12.         http://pshscripts.blogspot.com/2011/03/new-credentialps1.html 
  13. .PARAMETER UserId 
  14.    The userid in the form of "domain\user" 
  15. .PARAMETER Password 
  16.    The password for this user 
  17. .EXAMPLE 
  18.    New-Credential contoso\administrator  Pa$$w0rd 
  19. #> 
  20.  
  21. function New-Credential { 
  22. param ( 
  23. [string] $Userid, 
  24. [string] $Pwd 
  25. # Create the credential 
  26. $spwd = ConvertTo-SecureString -AsPlainText $pwd -Force  
  27. $cred = New-Object System.Management.Automation.PSCredential $userid,$spwd 
  28. # Now return it to the caller 
  29. return $cred 
  30.  
  31. # Call the function to demostrate example 
  32. New-Credential "contoso\administrator" "Pa$$w0rd" 
Technorati Tags: ,,