By default, Windows uses DHCP to configure any NICs that are found during the installation process. Once you complete the installation of Windows, you can use the settings application netsh.exe
, or, of course, PowerShell to set IP configuration manually.
This recipe runs on SRV2.Reskit.Org
. This host is a domain-joined system with an NIC that is initially set up to be configured from DHCP.
Get existing IP address information for
SRV2
:$IPType = 'IPv4' $Adapter = Get-NetAdapter | Where-Object Status -eq 'Up' $Interface = $Adapter | Get-NetIPInterface -AddressFamily $IPType $IfIndex = $Interface.ifIndex $IfAlias = $Interface.Interfacealias Get-NetIPAddress -InterfaceIndex $Ifindex -AddressFamily $IPType
Set the IP address for
SRV2
:$IPHT = @{ InterfaceAlias = $IfAlias PrefixLength = 24 IPAddress = '10.10.10.51' DefaultGateway = '10.10.10.254' AddressFamily = $IPType } New-NetIPAddress @IPHT | Out-Null