最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

修改ip接口的躍點(diǎn)數(shù)

2023-06-06 17:37 作者:限量版范兒  | 我要投稿

title: 修改網(wǎng)絡(luò)配置的 InterfaceMetric categories: ?- OS ?- Windows ?- 批處理

使用腳本修改網(wǎng)卡躍點(diǎn)數(shù) InterfaceMetric

使用到的接口

  1. Get-NetIPInterface

  2. Set-NetIPInterface

  3. Get-NetAdapter

需求描述

需要修改當(dāng)前躍點(diǎn)數(shù)為?1?的ip接口,修改其躍點(diǎn)數(shù)為?90

解決方案

設(shè)置ip接口的躍點(diǎn)數(shù)均需要管理員權(quán)限

思路一

源文件

  1. 通過?Get-NetIPInterface?獲取需要修改的IP接口

  2. 通過?Set-NetIPInterface?修改躍點(diǎn)數(shù)

$ChangeIfm = 1 $WangToChangeIfm = 90 # 獲取 InterfaceMetric 為 1 的 -InterfaceIndex $NetCard = (Get-NetIPInterface ?-InterfaceMetric $ChangeIfm).ifAlias $netInterfaceIndex = (Get-NetIPInterface -AddressFamily IPv4 -InterfaceMetric $ChangeIfm).ifIndex Write-Output "檢索InterfaceMetric為 [${ChangeIfm}] 列表: `n ${NetCard}" Write-Output "Index 為: ?${netInterfaceIndex}" Set-NetIPInterface -InterfaceIndex $netInterfaceIndex -InterfaceMetric $WangToChangeIfm Write-Output "已修改 ${NetCard} 的 InterfaceMetric 為 ${WangToChangeIfm}"

思路二

源文件

使用過濾器篩選需要修改的ip接口,再通過?Set-NetIPInterface?修改躍點(diǎn)數(shù)

# 獲取 InterfaceMetric 為 1 的 -InterfaceIndex $NetCard = (Get-NetAdapter | Where-Object -FilterScript {$_.ifIndex -eq 10}) Write-Output $NetCard Set-NetIPInterface -InterfaceIndex $NetCard.ifIndex -AddressFamily IPv6 -InterfaceMetric 90

官方demo

修改 LinkSpeed 為 100 Mbps 的網(wǎng)絡(luò)的 InterfaceMetric 為 21

Get-NetAdapter | Where-Object -FilterScript {$_.LinkSpeed -Eq "100 Mbps"} | Set-NetIPInterface -InterfaceMetric 21

提升管理員權(quán)限

cmd提權(quán)

@echo off ::1 獲取管理員權(quán)限 %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit ::2 執(zhí)行操作 set curpath=%~dp0 set file=ModifyIfm.ps1 set execPath=%curpath%%file% echo %execPath% powershell.exe -ExecutionPolicy ByPass -File %execPath%

powershell 提權(quán)

if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { ? ?if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { ? ? ? ?$Command = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments ? ? ? ?Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $Command ? ? ? ?Exit } }

原文鏈接:https://www.dianjilingqu.com/756397.html

修改ip接口的躍點(diǎn)數(shù)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
秀山| 五大连池市| 故城县| 沁阳市| 双峰县| 象山县| 甘德县| 叙永县| 墨江| 龙南县| 邮箱| 开封县| 洛扎县| 金乡县| 澎湖县| 桂阳县| 寿宁县| 桂平市| 浦北县| 盱眙县| 嘉鱼县| 营山县| 南充市| 宜春市| 宿州市| 高州市| 汉寿县| 苗栗市| 睢宁县| 桐柏县| 太湖县| 沾化县| 张北县| 屯留县| 班玛县| 崇礼县| 大庆市| 沽源县| 河南省| 阿拉善右旗| 右玉县|