Once your VMs have deployed, you’ll need to confirm the regional settings and enter the password for the administrator account (if you’ve followed the preceding posts), then your be dumped on the desktop. You could then configure the server manually, however this will need to repeated for every server. If these are 180 day evaluations, that’s going to become boring.
To make this a little easier I have created scripts for each of my VMs that I regulary use (i.e. DC, File Server, VMM Server, etc). The first script for each server is always the same except for the IP. Below are two examples of this script, 1 for PowerShell 2 (2008R2) and 1 for PowerShell 3 and above (2012/2012R2)
PowerShell 2 (Windows Server 2008R2, Windows 7)
# Set IP
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration| where{$_.IPEnabled -eq "TRUE”}
Foreach($NIC in $NICs) {
$NIC.EnableStatic("172.16.0.190","255.255.255.0")
$NIC.SetGateways("172.16.0.1")
$DNSServers = "172.16.0.67"
$NIC.SetDNSServerSearchOrder($DNSServers)
$NIC.SetDynamicDNSRegistration("FALSE")
}
#Activate windows
slmgr -ato
# Get the virtual machine name from the parent partition
$vmName = (Get-ItemProperty –path "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters”).VirtualMachineName
# Replace any non-alphanumeric characters with an underscore
$vmName = [Regex]::Replace($vmName,"\W","_")
# Trim names that are longer than 15 characters
$vmName = $vmName.Substring(0,[System.Math]::Min(15, $vmName.Length))
# Check the trimmed and cleaned VM name against the guest OS name
# If it is different, change the guest OS name and reboot
if ($env:computername -ne $vmName) {(gwmi win32_computersystem).Rename($vmName); shutdown -r -t 0}
PowerShell 3 and Above (Windows Server 2012/2012R2, Windows 8, 8.1)
# Set IP
Get-NetAdapter -Name E* | ? status -eq up | Rename-NetAdapter -NewName "Ethernet 2"
netsh interface ip set address name="Ethernet 2" static 172.16.0.67 255.255.255.0 172.16.0.1 1
netsh interface ip set dnsservers name="Ethernet 2" static 172.16.0.67
#Install Prod key
slmgr -upk
slmgr -ipk JGXYY-7NMTC-MHKY3-QCC9B-VQRG7
# Get the virtual machine name from the parent partition
$vmName = (Get-ItemProperty –path “HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters”).VirtualMachineName
# Replace any non-alphanumeric characters with an underscore
$vmName = [Regex]::Replace($vmName,"\W","_")
# Trim names that are longer than 15 characters
$vmName = $vmName.Substring(0,[System.Math]::Min(15, $vmName.Length))
# Check the trimmed and cleaned VM name against the guest OS name
# If it is different, change the guest OS name and reboot
if ($env:computername -ne $vmName) {(gwmi win32_computersystem).Rename($vmName); shutdown -r -t 0}
These scripts perform a few actions
Set the network card configuration (Change to suit your environment)
Either activate or update the product key (Change the key if not 2012R2 Eval)
Rename the VM name to the name specified in Hyper-v (I.e. I name my Server DC01 and TS01, so there hostnames will reflect this)
Reboot the server
I’ve created scripts for other tasks that are repeated each time you refresh the environment, I’ll try and post them soon.
Post 2: Hyper-V Host Configuration
Post 3 Creating the VM templates
Post 4 PS Script to deploy VMs
Post 5 Configure deployed VMs General