Today I would like to give a tutorial for a basic network configuration on Windows systems using PowerShell. We start with a fresh installation of a Windows operating system.
Retrieve Network Adapter ID
Run Get-NetAdapter to get the Network Adapter ID.
Make a note of the network adapter ID.
Configure IP-Address and Default Gateway
Next, configure the IPv4 Address and the Default Gateway with New-NetIPAddress. Provide your ifIndex ID of your network card. It certainly differs from mine.
New-NetIPAddress -InterfaceIndex 5 -IPAddress 192.168.99.202 -PrefixLength 24 -DefaultGateway 192.168.99.1
Configure DNS Server
We now need the ifIndex again to configure a DNS Server with Set-DnsClientServerAddress.
Set-DnsClientServerAddress -InterfaceIndex 5 -ServerAddresses 188.8.131.52,10.10.10.10
How do you know this worked ?
Run Get-NetIPConfiguration to review your work.