This script called ipsettings.ps1 can be used to retrieve the IP settings of a list of computers.

#
# Get IP settings of a list of computers
#
# Created    :     18/02/2012
# Updated    :    20/02/2012
#
# Authors    : jdalbera
# Comments    : This script returns IP settings of a list of computers
#            This script requires an input file called computers-list.csv
#            This input file contain a column = name
# Syntax: .\ipsettings.ps1
#
#
cls
Write-Host “”
Write-Host “———————————————”
Write-Host ” Get IP settings of a list of computers ”
Write-Host “———————————————”
Write-Host “”

## VARIABLES
$computerscsvlist = ‘.\computers-list.csv’
$date = Get-Date -Format ddMMyyyy
$log = “.\IPsettings-report-$date.txt”

# LOAD INPUT FILE
$computers = Import-Csv $computerscsvlist

# CMDLET – get-ipdetails
function get-ipdetails {
[CmdletBinding()]
param (
[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[string[]]$computername = $env:computername
)
process {
foreach ($Computer in $ComputerName) {
if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
$Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer | ? {$_.IPEnabled}
foreach ($Network in $Networks) {
$IPAddress  = $Network.IpAddress[0]
$SubnetMask  = $Network.IPSubnet[0]
$DefaultGateway = $Network.DefaultIPGateway
$DNSServers  = $Network.DNSServerSearchOrder
$IsDHCPEnabled = $false
If($network.DHCPEnabled) {
$IsDHCPEnabled = $true
}
$MACAddress  = $Network.MACAddress
$OutputObj  = New-Object -Type PSObject
$OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
$OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
$OutputObj | Add-Member -MemberType NoteProperty -Name SubnetMask -Value $SubnetMask
$OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value $DefaultGateway
$OutputObj | Add-Member -MemberType NoteProperty -Name IsDHCPEnabled -Value $IsDHCPEnabled
$OutputObj | Add-Member -MemberType NoteProperty -Name DNSServers -Value $DNSServers
$OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress
$OutputObj
}
}
}
}
}

# MAIN
foreach ($row in $computers)
{
$pctocheck = $row.name
Write-Host “Get IP settings of ” $pctocheck
get-ipdetails -computername $pctocheck | ft -AutoSize | Out-File $log -Append
Write-Host “”
Write-Host “——————————————————————————”
}
Write-Host “***********”
Write-Host ” completed ”
Write-Host “***********”
Write-Host “”