Configuring the network of virtual machines
To configure the network of a virtual machine guest operating system, you can use the Invoke-VMScript
cmdlet, to run scripts in the guest operating system of a virtual machine. You have already seen the Invoke-VMScript
cmdlet in
Chapter 5, Managing Virtual Machines with PowerCLI
.
To configure the network of Microsoft Windows virtual machines with PowerShell V3 or later versions installed, you can use the cmdlets in the netadapter
and NetTCPIP
modules to modify network adapters and TCP/IP settings. For Microsoft Windows virtual machines with PowerShell V1 or V2 installed, you can use the Windows Management Instrumentation (WMI)Â Get-WMIObject
cmdlet with the Win32_NetworkAdapterConfiguration
class. In this section, we will focus on using the cmdlets from the NetTCPIP
module.
Setting the IP address
The PowerShell cmdlet we will use for setting the IP address, network mask, and default gateway is New-NetIPAddress
. This cmdlet has the following syntax...