powershell script for setting windows ip addresses subnet and gateway and dns

Posted on 2011-09-30
Medium Priority
Last Modified: 2012-05-12
been googleing for a powershell script to set up all the ip address stuff for virtual 2008 r2 in a vmware 4.1 enviroment so i can use a script for a forth coming vitual server build / migration prject
Question by:IanTh
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Accepted Solution

Reubenwelsh earned 1500 total points
ID: 36890758
you can use NETSH to set the network config, it isnt really powershell but you can use it in Powershell just the same.

See here for how to do it: http://www.petri.co.il/configure_tcp_ip_from_cmd.htm
LVL 30

Author Comment

ID: 36890763
what if the virtual server has multiple nics

Expert Comment

ID: 36890835
Is there any logic in the network card names?
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

LVL 30

Author Comment

ID: 36890862
no its basically going to be something like a script that sets up the ip address the subnet and gateway with defaults for subnet if nothing entered

if second nic is required press yes

insert ip adress for second nic


Assisted Solution

Reubenwelsh earned 1500 total points
ID: 36890895
Ah ok... that makes it harder, when we did somthig like this i just copy pasted commandlines that set all the settings, dont really see the point of having popup dialougs, i just had an excelsheet ready and copy pasted from left screen to right screen, everything ready so no need to do any typing.
LVL 30

Author Comment

ID: 36891084
I am trying to setup script for a vmware 2008 r2 project that I am currently working on for the next part that I am trying to script a lot to cut down on finger trouble putting wrong details in asx the gateway and dns will not change just the ip address but thde servers will have multiple nics
LVL 30

Author Closing Comment

ID: 37197867
didn't answer fully
LVL 122
ID: 37449336

Have a look at this

One line!

Get-VM VMName | Get-VMGuestNetworkInterface -GuestUser Administrator -GuestPassword <password> -HostUser root -HostPassword <password> | Set-VMGuestNetworkInterface -IPPolicy Static -Ip <IPAddress> -Netmask -Gateway <Gateway> -GuestUser Administrator -GuestPassword <password> -HostUser root -HostPassword <password>

Open in new window

Also checkout Set-VMGuestNetworkInterface Options for DNS etc


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Teach the user how to edit .vmx files to add advanced configuration options Open vSphere Web Client: Edit Settings for a VM: Choose VM Options -> Advanced: Add Configuration Parameters:
Teach the user how to configure vSphere clusters to support the VMware FT feature Open vSphere Web Client: Verify vSphere HA is enabled: Verify netowrking for vMotion and FT Logging is in place or create it: Turn On FT for a virtual machine: Verify …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question