SHARE
TWEET

Untitled

a guest May 27th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function set-ethmetric
  2. {
  3. [CmdletBinding()]
  4. Param
  5. (
  6.     [Parameter(Mandatory=$false)]
  7.     [int]$Metric,
  8.     [Parameter(Mandatory=$false)]
  9.     [ValidateSet("Auto")]
  10.     [string]$AutoMetric = 'Auto'
  11.    
  12. )
  13.     if ($Metric -eq $Null)
  14.         {$met = $AutoMetric}
  15.     else {$met = $Metric}
  16.     $adapter = Get-WmiObject -Class win32_networkAdapter | Where-Object Name -Like '*Ethernet*'
  17.  
  18.     # Change IPv4 metric
  19.     $Adapterstring_ipv4 = 'netsh interface ipv4 set interface "' + $adapter.NetConnectionID +'" metric=' +$met
  20.     cmd.exe /C $Adapterstring_ipv4
  21.     # Change IPv6 metric
  22.     $Adapterstring_ipv6 = 'netsh interface ipv6 set interface "' + $adapter.NetConnectionID +'" metric=' +$met
  23.     cmd.exe /C $Adapterstring_ipv6
  24.  
  25.    
  26. }
  27.  
  28.  
  29. set-ethmetric -Metric 51
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top