Powershell 設定網路卡 IP
網卡設定通常設好一次就不會再動了,但是如果你的筆電和你趴趴造,雖然開那個網路設定要按好幾下,才能進去把 DHCP 再開起來,已經讓你無奈地習以為常,那…那…那…有沒有可能,只要按一下就好? 工作環境: Windows 10 Home Powershell Powershell script 當然,不一定要用 Powershell 才能達成這個效果,用傳統的 CMD 指令終端機也是可以,可以參照 這裏 ,大致上用到以下這些指令: netsh interface ip set address “Network Interface Name” dhcp netsh interface ip set address name= “Network Interface Name” static [IP address] [Subnet Mask] [Gateway] net interface ipv4 set dns name="Wi-Fi" static 8.8.8.8 [index=2] net interface ipv4 set dnsservers name="Wi-Fi" source=dhcp 最常用到的設定模式就是自動取得 IP 了,如果一定要用 Powershell 來完成的話,要找的指令和要調整的參數不少,參考了不少網站,完成後,長得大致上像這樣: #移除 default-gateway Remove-NetRoute -Confirm:$false #移除 IP Remove-NetIpAddress -Confirm:$false #移除 DNS servers Set-DnsClientServerAddress -InterfaceAlias '乙太網路' -ResetServerAddress #移除 DNS 快取 Clear-DnsClientCache #設定自動取得 IP 位址 Set-NetIPInterface -InterfaceAlias '乙太網路' -Dhcp Enabl...