Configure Network Configuration (IP-Address, DNS, Default Gateway) with PowerShell

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 -PrefixLength 24 -DefaultGateway

Configure DNS Server

We now need the ifIndex again to configure a DNS Server with Set-DnsClientServerAddress.

Set-DnsClientServerAddress -InterfaceIndex 5 -ServerAddresses,

How do you know this worked ?

Run Get-NetIPConfiguration to review your work.

Mission accomplished.

Categories: PowerShell

Tagged as: ,

1 reply »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.