HOWTO : Configure IP network settings with Powershell.

0 Flares Filament.io 0 Flares ×

Windows 2012 finally delivered a set of cmdlets for managing network connection. The cmdlets for networking you can find on the Technet site. But I’m still stuck with Windows 2008 R2 and I need to set up IP address on the servers during installation/configuration phase. For that I’ll be using the xml input file

In the ideal situation I will have only one network adapter in my machine and than script is quite easy to write. I will use Win32_NetworkAdapterConfiguration WMI class.

Problem starts if there are more network adapters used in server and the condition  where {$_.IPEnabled -eq $true}  becomes useless.

For such case, I need something more to define the proper network connection to configure. So first condition useful, but not best, using the network connection name.

Virtual_Network_Setup_Step5
So my xml input file will look like

and it complicates script a little bit, because ConnectionName is not part of Win32_NetworkAdaperConfiguration, but Win32_NetworkAdapter, so I need to modify script a little bit.

So first in the script I’m looking for a adapter with the specified connection name and then I’m matching this adapter to proper configuration, rest of script remains the same.

Of course best thing to defining proper network adapter is MAC address, so if I use MAC instead of connection name it would make my life easier, then xml file would look like this

Now script looks quite similar like first one, using just Win32_NetworkAdapterConfiguration WMI class

Then based on the input file, IP address will be set up with the script, which can be used in any automation process using SCCM or any just a scripted automation.

0 Flares LinkedIn 0 Google+ 0 Facebook 0 Twitter 0 Filament.io 0 Flares ×

Leave a Reply

Your email address will not be published. Required fields are marked *