【发布时间】:2017-09-22 01:47:34
【问题描述】:
我正在尝试创建一个 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**
谁能告诉我如何写一个条件来完成我正在寻找的东西?
【问题讨论】:
-
使用 -Name 参数尝试 Get-NetAdapter
-
你可以使用
Get-NetIPInterface |? {$_.NlMtu -lt 1600}
标签: powershell