启用跳跃框架



我正在尝试创建一个PowerShell脚本,以在OpenStack Windows VM上启用Jumpframe。查找活动网卡以及当前MTU值的命令也将在下面更改MTU值的命令。

从下面的命令中,我首先找到活动网卡,然后尝试找到该NIC的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**

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

尝试以下内容:

$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