Advertisement
Guest User

Script that blocks login attempts

a guest
Jul 23rd, 2021
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $computer='localhost'
  2. $username = gwmi win32_computersystem -comp $computer | select Username
  3. $userstring = [string]$username
  4. $usernamejunk,$adilstu_user = $userstring.Split("=",2)
  5. $usernameonly,$usernamebracket = $adilstu_user.Split("}",2)
  6. $date = (Get-Date).ToString('HH')
  7. $FilePath = 'C:\Users\User\Desktop\restartet.txt'
  8.  
  9. IF([string]::IsNullOrEmpty($usernameonly)) {  
  10.  
  11.     IF([string]::IsNullOrEmpty((Get-Content $FilePath))) {
  12.         Out-File -FilePath $FilePath -InputObject $date
  13.         Restart-Computer -Force
  14.     }  
  15.  
  16.     else {            
  17.         exit
  18.     }
  19.  
  20. }
  21. else {            
  22.     write-host "Benutzer ist noch angemeldet"
  23. }  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement