启用跳帧

时间:2017-09-21 04:20:18

标签: powershell

我正在尝试创建一个powershell脚本,以在Openstack Windows VM上启用Jumpframe。查找活动网卡的命令以及当前MTU值也是改变MTU值的命令。

从下面的命令我首先找到活动的网卡,然后尝试找到该网卡的MTU值,如果我发现MTU值小于1600,我需要将其更改为9000。

PS C:\> **wmic nic where "netconnectionid like '%'" get netconnectionid**
NetConnectionID
Ethernet

PS C:\> **netsh.exe int ipv4 show subint**

   MTU  MediaSenseState   Bytes In  Bytes Out  Interface
------  ---------------  ---------  ---------  -------------
4294967295                1          0       1400  Loopback Pseudo-Interface 1
  1200                1  1335974344    5867793  Ethernet

PS C:\> **netsh int ipv4 set subint "Ethernet" mtu=9000 store=persistent**

任何人都可以让我知道如何写出条件来完成我想要的东西?

1 个答案:

答案 0 :(得分:0)

尝试以下方法:

$enabledAdaptersNames = Get-NetAdapter |? {$_.status -eq "Up" -or $_.status -eq "Disconnected"} | Select -ExpandProperty name

Get-NetIPInterface |? { $enabledAdapterNames -contains $_.InterfaceAlias -and $_.NlMtu -lt 1600} |  Set-NetIPInterface -NlMtuBytes 9000
相关问题