Forum

Please or Register to create posts and topics.

NIC IP Pull

This script is used to pull NIC IP Address information from a list of servers (servers.txt) that you supply.

$File = @()
$ser = @()

#get current directoy
$scriptpath = $MyInvocation.MyCommand.Path
$currentdir = Split-Path $scriptpath

#import "Servers.txt" into an array
$importloc = $currentdir + "\servers.txt"
$input = get-content $importloc

#Create new CSV based on the fileserver name
$outputpath = $currentdir + "\NicPull.csv"

del $outputpath -force

"Server `t IPAddress 1 `t IPAddress 2 `t IPAddress 3 `t IPAddress 4 `t IPAddress 5" >> $outputpath

foreach($comp in $input){
$output = @()
$IPSettings = @()
$NicSettings = @()

$NicSettings = gwmi Win32_NetworkAdapterConfiguration -Comp $comp | where{$_.IPEnabled -eq "True"}
$Output = "$comp `t "
foreach($item in $NicSettings){
$Item = $Item.ipaddress
$Output = $Output + "$item `t "

}
$Output >> $outputpath
$output = @()
}

 

COMMENTS