다음을 통해 공유


Change the IP Address v4 of a Computer using Powershell Script

Dear All,

I was working on one of the project which required the change of the IP v4 Address to static IP Address and then to again flip back to the Dynamic Address. I thought of checking if PowerShell could be helpful. And guess what! It is too good for a tool!! 

Below are the scripts i wrote:

For changing it to Static IP Address: 

$wmi = Get-WMIObject Win32_NetworkAdapterConfiguration -computername . | where{$_.Description -eq "Description parameter of the Network card"}
$wmi.EnableStatic("Ststic IP Address", "subnet mask")
$wmi.SetGateways("Default Gateway", 1)
$dns = ("first DNS Server Address", "Second DNS Server Address")

$wmi.SetDNSServerSearchOrder($dns)

For changing the IP Address to Dynamic: 

$wmi = Get-WMIObject Win32_NetworkAdapterConfiguration -computername . | where{$_.Description -eq "Description parameter of the Network card"}
$wmi.EnableDHCP()

$wmi.SetDNSServerSearchOrder()

Hope the above scripts helps all and makes life easy...! 

In the end Happy PowerShelling..! 

Regards, KETAN
MCITP- Messaging: Exchange Server 2010
MCTS- Communication: Lync Server 2010