Retrieve the IP configuration of all Windows Servers with Get-NetIPServerInfo

In this blog post it’s all about documentation. Do you know the IP settings of your Windows servers? Do you have a documentation? If not, you’ve come to the right place. I will give you an advanced function in hand that enables you to obtain the IP configuration of all your servers. With PowerShell, what else?

The Output

Let’s first talk about the goal. We want to retrieve the IP address, the interface, the default gateway and last but not least the configured DNS servers. That DNS server settings could become crucial if you plan to replace your domain controllers with new ones and with different IP addresses than the old servers.

Note that all servers should be joined to the same domain. Here it is in action and in list format:



… in table format

Get-NetIPServerInfo | Format-Table -AutoSize


… in html format

Get-NetIPServerInfo | ConvertTo-Html -As Table | Set-Content C:\servers.htm


Nice ones. So, what’s next? Sure, the code.


# Get-NetIPServerInfo gets the IP configuration of all domain joined Windows servers.

# Uses Test-Connection to check if the server is powered on and reachable.

# Get-NetIPServerInfo | Format-Table -AutoSize

# Author: Patrick Gruenauer
# Web: https://sid-500.com

function Get-NetIPServerInfo {

$getc=(Get-ADComputer -Filter 'operatingsystem -like "*server*"-and enabled -eq "true"').Name
$test=Test-Connection -Destination $getc -Count 1 `
-ErrorAction SilentlyContinue
$reach=$test | Select-Object -ExpandProperty Address

foreach ($c in $reach)

$i=Invoke-Command -ComputerName $c -ScriptBlock {

Get-NetIPConfiguration |
Select-Object `
-Property InterfaceAlias,Ipv4Address,DNSServer
Get-NetRoute -DestinationPrefix '' |
Select-Object -ExpandProperty NextHop}

$result +=New-Object -TypeName PSCustomObject -Property ([ordered]@{
'Server'= $c
'Interface' = $i.InterfaceAlias -join ','
'IPv4Address' = $i.Ipv4Address.IPAddress -join ','
'Gateway' = $i | Select-Object -Last 1
'DNSServer' = ($i.DNSServer |
Select-Object -ExpandProperty ServerAddresses) -join ','



How to use it

Copy the code into your PowerShell ISE session and run the code. Then type the command and have fun with it.

If you want to make the function permanent available, so that the function is there every time you start PowerShell, you have to create a folder in C:\Program Files\WindowsPowerShell\Modules. Name it Get-NetIPServerInfo. Then save the code as .psm1 file in that folder. The screenshot below will be a great help.


4 replies »

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 )

Google+ photo

You are commenting using your Google+ 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.