Link to home
Start Free TrialLog in
Avatar of IanTh
IanThFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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

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
ASKER CERTIFIED SOLUTION
Avatar of Reubenwelsh
Reubenwelsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IanTh

ASKER

what if the virtual server has multiple nics
Avatar of Reubenwelsh
Reubenwelsh

Is there any logic in the network card names?
Avatar of IanTh

ASKER

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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IanTh

ASKER

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
Avatar of IanTh

ASKER

didn't answer fully
Avatar of Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
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