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

Posted on 2011-09-30
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 500 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:
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?
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

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 500 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 120
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dVswitch 11 32
Bing Maps Add-in in Exchange 2016 1 73
Windows 10 Virtual Machine Backup 9 65
Add server count in powershell 4 18
The following article is comprised of the pearls we have garnered deploying virtualization solutions since Virtual Server 2005 and subsequent 2008 RTM+ Hyper-V in standalone and clustered environments.
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 …
Teach the user how to install and configure the vCenter Orchestrator virtual appliance Open vSphere Web Client: Deploy vCenter Orchestrator virtual appliance OVA file: Verify vCenter Orchestrator virtual appliance boots successfully: Connect to the …
In this video tutorial I show you the main steps to install and configure  a VMware ESXi6.0 server. The video has my comments as text on the screen and you can pause anytime when needed. Hope this will be helpful. Verify that your hardware and BIO…

738 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