Camera Icon

Got an event that needs shooting?  I've covered multiple events for marathon-photos.com and can capture the scenes & emotions that make your event unique.

Some samples of my own work are at Digital Formula on Flickr.

Wand Icon

Do you or your business need a website but you're unsure where to start?  Get in touch now and we'll get it sorted.

I focus on usable functionality & can setup smaller sites using Wordpress within hours of the order being placed.  Magic!

Globe Icon

So, you've already got a website but need help managing it?  I can help you.

Don't worry about knowing every single detail.  I'll find out the most important stuff and work with you to reach your goal, not someone else's.

said on twitter: oooOOOooo beta invitation to #Wunderkit from @6Wunderkinder has been approved. Exciting! (@toni_b pants-wettingly exciting lol)

 
0 comments
Short URL

Set network interface IP address with Powershell

The Problem

While setting up our partner technology centre recently, I found myself switching back and forth between networks so often that I was constantly having to change my laptop’s IP address. For reasons that are outside the scope of this article I’m unable to use the option for an alternate network configuration.

Powershell to the rescue

The solution? Two small Powershell scripts - one to setup my network connection for our corporate LAN, the other to setup my network connection for the PTC. The scripts are shown below - feel free to use them in any way you like.

PTC configuration script

$index = (gwmi Win32_NetworkAdapter | where {$_.netconnectionid -eq “Local Area Connection”}).InterfaceIndex
$NetInterface = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.InterfaceIndex -eq $index}
$NetInterface.EnableStatic(“10.0.0.10”, “255.255.255.0”)
$NetInterface.SetDynamicDNSRegistration(“FALSE”)

Corporate LAN configuration script

This script just resets the network adapter back to DHCP

$index = (gwmi Win32_NetworkAdapter | where {$_.netconnectionid -eq “Local Area Connection”}).InterfaceIndex
$NetInterface = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.InterfaceIndex -eq $index}
$NetInterface.EnableDHCP()
$NetInterface.SetDynamicDNSRegistration(“TRUE”)

Extra stuff

Although I don’t need them in my PTC environment (it’s internal only, with no internet access), you can also use the snippets below to add some extra functionality.

$NetInterface.SetGateways($gateway)
$NetInterface.SetDNSServerSearchOrder($dns)
# (e.g. “10.10.1.1” for single server or “10.10.1.1,10.10.1.2” for multiple servers)
$NetInterface.SetDynamicDNSRegistration($registerDns)
» Tags: powershell, tcpip, network, ip, configuration
DigitalFormula is an experiment in HTML5 and CSS3 design by Chris Rasmussen, an amateur/casual designer based in Melbourne, Australia. -37.813611 144.963056