In the Creating a virtual machine recipe, you created a VM, VM1
. This virtual machine has, by default, a single network card that Hyper-V sets to acquire IP address details from DHCP. In this recipe, you assign the NIC to a switch and configure IP address details.
This recipe assumes you have created VM1
as per the Creating a virtual machine recipe. The recipe also makes use of a DHCP server running on DC1
. You set this DHCP server up in the Installing and authorizing a DHCP Server recipe, and configured the DHCP server in the Configure DHCP scopes recipe, in Chapter 8, Managing Windows Network Services.
Here you see how to configure Hyper-V networking:
- Get NIC details and any IP Address from the
VM1
VM:
Get-VMNetworkAdapter -VMName VM1
- Get VM networking details:
$user = 'Localhost\Administrator' $pass = ConvertTo-SecureString -String 'Pa$$w0rd' ` -AsPlainText -Force $cred = New-Object -TypeName...