Advertisement
DanielAagaard

Pwshell users

Apr 9th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function show-menu
  2. {
  3.  param(
  4.  [string]$tekst = "User Administration Menu"
  5.  )
  6. clear-host
  7. Write-host "============================================="
  8. Write-host "============= $tekst ======"
  9. Write-host "============= By Daniel Aagaard ============="
  10. Write-host "============================================="
  11. Write-host "1: Please Press '1' to delete existing user"
  12. Write-host "2: Please Press '2' to add a new user"
  13. Write-host "3: Please Press '3' to add 5 login attempts and 15m lockout"
  14. Write-host "Q: Please Press 'Q' to Quit"
  15. }
  16. do{
  17.  
  18. show-menu
  19.  
  20. $Selection = read-host "Please make a Selection"
  21.  
  22.  
  23. switch ($Selection)
  24. {
  25.  '1'{
  26.  write-host 'You have Chosen to Delete an existing user' -ForegroundColor Red
  27.  $deluser = read-host "Please input username to Delete"
  28.   NET USER $deluser /delete
  29.  sleep -seconds 4
  30.  }
  31.  '2'{
  32.  write-host 'You have Chosen to Add a new user' -foregroundcolor green
  33.  $username = read-host "Please input Username"
  34.  $Password = read-host "Please input Password"
  35.   NET USER $username $password /add
  36.   write-host 'User has been added'
  37.  sleep -seconds 5
  38.  }
  39.  '3'{
  40.  secedit /export /cfg c:\secpol.cfg
  41.  (gc c:\secpol.cfg).  replace("PasswordComplexity = 0", "PasswordComplexity = 1") | out-File C:\secpol.cfg
  42.  (gc c:\secpol.cfg).  replace("LockoutBadCount = 0", "LockoutBadCount = 5") | out-File C:\secpol.cfg
  43.  (gc c:\secpol.cfg).  replace("ResetLockoutCount = 30", "ResetLockoutCount = 15") | out-File C:\secpol.cfg
  44.  (gc c:\secpol.cfg).  replace("LockoutDuration = 30", "LockoutDuration = 15") | out-File C:\secpol.cfg
  45.  secedit /configure /db c:\windows\security\local.sdb /cfg c:\secpol.cfg /areas SECURITYPOLICY
  46.  rm -force C:\secpol.cfg -confirm:$false
  47.  Write-host 'You have changed Security Policy'
  48.  sleep -seconds 4
  49.  }
  50.  'Q'{
  51.  write-host 'Closing Script, Goodbye!'
  52.  sleep -seconds 3
  53.  Return
  54.  }
  55.  Default {write-warning 'Invalid Selection. Please try Again'
  56.  sleep -seconds 3
  57. }
  58.  
  59. }
  60. }
  61. Until ($selection -eq 'q')
  62. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement