Advertisement
thebys

Two line firewall rule add with autoelevator in powershell

Oct 14th, 2016
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Autoelevator
  2. if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
  3.  
  4. #Add firewall rule of your liking.
  5. netsh advfirewall firewall add rule name="Webserver autoconfig 7777 TCP INBOUND" dir=in action=allow protocol=TCP localport=7777
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement