Solved

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

Posted on 2011-09-30
10
1,054 Views
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
0
Comment
Question by:IanTh
  • 4
  • 3
10 Comments
 
LVL 6

Accepted Solution

by:
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: http://www.petri.co.il/configure_tcp_ip_from_cmd.htm
0
 
LVL 30

Author Comment

by:IanTh
ID: 36890763
what if the virtual server has multiple nics
0
 
LVL 6

Expert Comment

by:Reubenwelsh
ID: 36890835
Is there any logic in the network card names?
0
 
LVL 30

Author Comment

by:IanTh
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 255.255.255.0 if nothing entered


if second nic is required press yes

insert ip adress for second nic


etc
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 6

Assisted Solution

by:Reubenwelsh
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.
0
 
LVL 30

Author Comment

by:IanTh
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
0
 
LVL 30

Author Closing Comment

by:IanTh
ID: 37197867
didn't answer fully
0
 
LVL 117
ID: 37449336
Ian

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 255.255.252.0 -Gateway <Gateway> -GuestUser Administrator -GuestPassword <password> -HostUser root -HostPassword <password>

Open in new window


Also checkout Set-VMGuestNetworkInterface Options for DNS etc

http://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/Set-VMGuestNetworkInterface.html
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article will help you understand what HashTables are and how to use them in PowerShell.
HOW TO: Install and Configure VMware vSphere Hypervisor 6.5 (ESXi 6.5), Step by Step Tutorial with screenshots. From Download, Checking Media, to Completed Installation.
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 …
Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now