Advertisement
redleader36

add-route-from-url

Feb 2nd, 2021
1,201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param (
  2.     [string]$url = "music.youtube.com"
  3. )
  4.  
  5. $gateway = 192.168.1.1
  6.  
  7. $addresses = ( Resolve-DnsName $url ).IP4Address
  8. foreach ( $address in $addresses ) {
  9.     Write-Host "route -p add $address $gateway"
  10. }
  11.  
  12. # this elevates to admin
  13. if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))  
  14. {  
  15.   $arguments = "& '" +$myinvocation.mycommand.definition + "'"
  16.   Start-Process powershell -Verb runAs -ArgumentList $arguments
  17.   Break
  18. }
  19.  
  20. foreach ( $address in $addresses ) {
  21.     route -p add $address $gateway
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement