Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function show-menu
- {
- param(
- [string]$tekst = "User Administration Menu"
- )
- clear-host
- Write-host "============================================="
- Write-host "============= $tekst ======"
- Write-host "============= By Daniel Aagaard ============="
- Write-host "============================================="
- Write-host "1: Please Press '1' to delete existing user"
- Write-host "2: Please Press '2' to add a new user"
- Write-host "3: Please Press '3' to add 5 login attempts and 15m lockout"
- Write-host "Q: Please Press 'Q' to Quit"
- }
- do{
- show-menu
- $Selection = read-host "Please make a Selection"
- switch ($Selection)
- {
- '1'{
- write-host 'You have Chosen to Delete an existing user' -ForegroundColor Red
- $deluser = read-host "Please input username to Delete"
- NET USER $deluser /delete
- sleep -seconds 4
- }
- '2'{
- write-host 'You have Chosen to Add a new user' -foregroundcolor green
- $username = read-host "Please input Username"
- $Password = read-host "Please input Password"
- NET USER $username $password /add
- write-host 'User has been added'
- sleep -seconds 5
- }
- '3'{
- secedit /export /cfg c:\secpol.cfg
- (gc c:\secpol.cfg). replace("PasswordComplexity = 0", "PasswordComplexity = 1") | out-File C:\secpol.cfg
- (gc c:\secpol.cfg). replace("LockoutBadCount = 0", "LockoutBadCount = 5") | out-File C:\secpol.cfg
- (gc c:\secpol.cfg). replace("ResetLockoutCount = 30", "ResetLockoutCount = 15") | out-File C:\secpol.cfg
- (gc c:\secpol.cfg). replace("LockoutDuration = 30", "LockoutDuration = 15") | out-File C:\secpol.cfg
- secedit /configure /db c:\windows\security\local.sdb /cfg c:\secpol.cfg /areas SECURITYPOLICY
- rm -force C:\secpol.cfg -confirm:$false
- Write-host 'You have changed Security Policy'
- sleep -seconds 4
- }
- 'Q'{
- write-host 'Closing Script, Goodbye!'
- sleep -seconds 3
- Return
- }
- Default {write-warning 'Invalid Selection. Please try Again'
- sleep -seconds 3
- }
- }
- }
- Until ($selection -eq 'q')
- pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement