PowerShell set Satic IP DNS Gateway SubNet

PowerShell modification to Network adapter from script

Network Adapter Configuration

  •  set Satic IP
  • set SubnetMask
  •  set Gateway  
  • set DNS Server
#########################################################
##Author: brilliantlyeasy.com
#network_change.ps1
# modification to Network adapter -
##########################################################

$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration |
 where{$_.IPEnabled -eq "TRUE"}
Foreach($NIC in $NICs) {
#change in quotes to yor ip address
#set static IP and Subnet
$NIC.EnableStatic("192.xxx.xxx.xxx", "255.255.255.0")
#set gateway
$NIC.SetGateways("192.XX.XX.XX")
#set DNS Servers
$DNSServers = "192.XX.XX.XX","192.XX.XX.XX"
$NIC.SetDNSServerSearchOrder($DNSServers)
$NIC.SetDynamicDNSRegistration("FALSE")
}

The above script can be handy when you need to set a number
of server IP addresses.
Example:
When a company decides to change entire address scheme
is implemented.

share with friends

Share to Google Buzz
Share to Google Plus
Share to LiveJournal
Share to Odnoklassniki

One Response to PowerShell set Satic IP DNS Gateway SubNet