Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module C:\MikroTik\Mikrotik.dll
- $MikroTik=Connect-Mikrotik -IPaddress 192.168.88.1 -UserName admin -Password XXXXX
- $ip=$args[0]
- $login=$args[1]
- $ipRegEx="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
- 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.*")
- {
- $textscript='script={:global badRdpLogin; $badRdpLogin banip="'+$ip+'" banlogin="'+$login+'"}'
- Send-Mikrotik -Connection $MikroTik -Command '/execute' -Attributes $textscript
- }
- Disconnect-Mikrotik -Connection $MikroTik
- # Pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement