Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# .SYNOPSIS
# Get-NetIPServerInfo gets the IP configuration of all Computers passed as parameters
# .DESCRIPTION
# Uses Test-Connection to check if the server is powered on and reachable.
# .EXAMPLE
# Get-NetIPServerInfo -Computername server1, server2
#.EXAMPLE
# 'server1', 'server2' | Get-NetIPServerInfo | Format-Table
# .NOTES
# Author: Patrick Gruenauer
# Web: https://sid-500.com
#
# Made to accept computernames as parameters by Pål Røtnes
# gomibushi@gmail.com
function Get-NetIPServerInfo {
[CmdletBinding()]
Param (
[parameter(Mandatory=$true,ValueFromPipeline=$true)]
[Array]$Computername
)
Process
{
foreach ($c in $Computername)
{
$i=Invoke-Command -ComputerName $c -ScriptBlock {
Get-NetIPConfiguration |
Select-Object `
-Property InterfaceAlias,Ipv4Address,DNSServer
Get-NetRoute -DestinationPrefix '0.0.0.0/0' |
Select-Object -ExpandProperty NextHop
}
$result = $null
$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 ','
})
$result
}
}
}
@gomibushi

This comment has been minimized.

Copy link
Owner Author

commented Oct 29, 2018

You can find the original script here:
https://sid-500.com/2018/10/26/retrieve-the-ip-configuration-of-all-windows-servers-with-get-netipserverinfo/
Thanks for the difficult code! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.