三三世界-百宝箱

文章 分类 标签
130 9 247

公告

暂无站点公告

PowerShell设定网卡,ip,网关,dns等命令

三三 2022-05-11 2145 0条评论 Windows使用 powershell添加ip

首页 / 正文

--------------【系统需求】--------------
不支持win7,win2008r2

支持win8及以上

支持windowns server 2012及以上。windows2012,windows2016,windows 2019等

--------------【获取网卡】--------------
获取所有网卡:

Get-NetAdapter

获取单个网卡:

Get-NetAdapter -Name "Ethernet0" #或以太网,

或:

Get-NetAdapter -InterfaceIndex 8

获取网卡物理信息

Get-NetAdapterHardwareInfo

--------------【获取ip,网关等】--------------

Get-NetIPConfiguration -InterfaceAlias Ethernet0 -Detailed#或以太网,

#获取ip

(Get-NetAdapter -Name ethernet0 | Get-NetIPAddress).IPv4Address

--------------【重启网卡】--------------

Restart-NetAdapter -InterfaceAlias Ethernet0 #或以太网

--------------【设定ip,网关】--------------

在远程win2019上,更改ip。更改成功后会卡死,需要重新用新ip连接win2019。

(Get-NetAdapter)[-1] | New-NetIPAddress -AddressFamily IPv4 -IPAddress 192.168.11.220 -PrefixLength 8 -DefaultGateway 192.168.11.1

#更改ip

(Get-NetAdapter)[-1] | Set-NetIPAddress  -IPAddress 192.168.11.90

#设定成从dhcp获取

(Get-NetAdapter)[-1] | Set-NetIPInterface -Dhcp Enabled

禁用ipv6

(Get-NetAdapter)[-1]| Disable-NetAdapterBinding -ComponentID ms_tcpip6

--------------【设定dns】--------------

(Get-NetAdapter)[-1] | Set-DNSClientServerAddress -ServerAddresses 192.168.11.1,114.114.114.114

#自动获取dns

(Get-NetAdapter)[-1] |Set-DnsClientServerAddress -ResetServerAddresses

--------------【服务器改名】--------------
Rename-Computer -ComputerName . -NewName
ps#这条命令不支持中文名。

Get-WmiObject win32_computersystem).rename('ps三三2022') #good

--------------【设定路由】--------------
添加:

New-NetRoute -DestinationPrefix "0.0.0.0/0" -NextHop "192.168.12.2" -InterfaceIndex 8

删除:

Set-NetIPInterface -InterfaceAlias Ethernet0| Remove-NetRoute -Confirm:$false

评论(0)

当前没有评论,还不快来留下第一个脚印吧


Copyright 2021 三三世界-百宝箱. All Rights Reserved.

最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年07月

 123456
78910111213
14151617181920
21222324252627
28293031   

文章目录

上一张 下一张