Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Import-Module C:\MikroTik\Mikrotik.dll
  2.  
  3. $MikroTik=Connect-Mikrotik -IPaddress 192.168.88.1 -UserName admin -Password XXXXX
  4.  
  5. $ip=$args[0]
  6. $login=$args[1]
  7. $ipRegEx="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
  8. if($ip -match $ipRegEx -and $ip -notlike "127.*" -and $ip -notlike "10.*" -and $ip -notlike "169.254.*" -and $ip -notlike "172.16.*" -and $ip -notlike "172.17.*" -and $ip -notlike "172.18.*" -and $ip -notlike "192.168.*")
  9. {
  10.     $textscript='script={:global badRdpLogin; $badRdpLogin banip="'+$ip+'" banlogin="'+$login+'"}'
  11.     Send-Mikrotik -Connection $MikroTik -Command '/execute' -Attributes $textscript
  12. }
  13.  
  14. Disconnect-Mikrotik -Connection $MikroTik
  15. # Pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement