nGX
nGX

Reputation: 1068

How to configure a VM from HyperV host using Powershell

I have a HyperV server with over 10 VMs hosted on it. They all use a base image so they are not connected to a domain nor do they have there NIC configured. Is there a way that I could run commands from the host to configure the VMs NIC and join the domain as if I was actually logged in?

This is easily done if I just pop open the VM from HyperV:

###Joining domain###

$domain = "mydomain.gbl"
$cred = get-credential mydomain\defaultuser

Add-Computer -DomainName $domain -Credential $cred

Now this approach is ok if I had only a few machines but since I have so many and even more machines to come that need configuration, I am trying to find a way to automate these tasks.

Maybe I could create a scheduled task on the VMs from the host?

Upvotes: 0

Views: 720

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200463

Since you're running Server 2008 your only option (AFAICS) would be to configure the network interfaces of the VMs with static MAC addresses (e.g. with the PowerShell Management Library for Hyper-V), set up a DHCP to provide the VMs with IP addresses. After that you should be able to do something e.g. with PsExec if the Windows Firewall is disabled on the VMs. If it isn't, you'll have to log in manually. You need at least some basic configuration for remote management.

Upvotes: 0

Related Questions