Hi,
Last Sunday one of my friend come to visit me at my home, he is a SQL Administrator and we were talking about Powershell, and he told me that he is facing a problem, he said that in their environment they have approx. 500 Servers and they want to know the network configuration of all of them and specially they needed the SUBNET mask information, because their SUBNETMASK are based on geographic locations.
For him i wrote a simple script which can query multiple server using WMI.
Download the script from this link : http://gallery.technet.microsoft.com/scriptcenter/Get-Network-Information-of-6d07766f
You need to add computer names separated by commas in the front of the script.
Make sure that you run this script as ADMINISTRATOR if you want to run this script for remote computers.
Download the script from this link : http://gallery.technet.microsoft.com/scriptcenter/Get-Network-Information-of-6d07766f
Thanks
Aman Dhally
I love it, this is one of the best scripts you wrote, atleast for me 😉
Keep helping the community.
Cheers!
You are welcome Brother 🙂
i glad that this scrip helped you ;o)
thanks
aman
Hi Aman!
Alex from FB-ScriptingGuys-Group here…
I ran your script on my computer, but I received no results..
Doing some reseach, I found out, that the $nwINFO variable formed an array, because I have more than one active network adapter.
So I was curious how to solve that…
Here is my approach, which works for me and I want to share (as you always share your scripts for the community 🙂 )
————————
foreach ( $Computer in $arrComputer ) {
$nwINFO = Get-WmiObject -ComputerName $Computer Win32_NetworkAdapterConfiguration | Where-Object { $_.IPAddress -ne $null } #| Select-Object DNSHostName,Description,IPAddress,IpSubnet,DefaultIPGateway,MACAddress,DNSServerSearchOrder | format-Table * -AutoSize
#| Select-Object DNSHostName,Description,IPAddress,IpSubnet,DefaultIPGateway,MACAddress,DNSServerSearchOrder
For ($i = 0; $i -lt $nwINFO.count; $i++) {
$nwServerName = $nwINFO[$i].DNSHostName
$nwDescrip = $nwINFO[$i].Description
$nwIPADDR = $nwINFO[$i].IPAddress
$nwSUBNET = $nwINFO[$i].IpSubnet
$nwGateWay = $nwINFO[$i].DefaultIPGateway
$nwMacADD = $nwINFO[$i].MACAddress
$nwDNS = $nwINFO[$i].DNSServerSearchOrder
# Server/CompName |NetworkCard | IPAdress | SubnetMask| Gateway | MAC Address| DNS |
Write-Host “$nwServerName | $nwDescrip | $nwIPADDR | $nwSUBNET | $nwGateWay | $nwMacADD | $nwDNS ” | ft *
}
}
————————
Cheers,
Alex
HI Alex,
Nice find and actually i never think that someone may have two or more IP Enabled Connections..
Thanks for correction and as i say from sharing everyone gets benefited and everyone learn new things.
Thanks for share 🙂 and i do know you ;o)
Thanks
Aman
Hi,
There is another alternative to this, by inserting another ‘foreach’ loop.
param (
[array]$arrComputer=”$env:computername”
)
“`n”
Write-Host “Name| NetworkCard | IP | SUBNET | GateWay | MacADD | DNS ” -ForegroundColor Green
foreach ( $Computer in $arrComputer ) {
$nwINFO = Get-WmiObject -ComputerName $Computer Win32_NetworkAdapterConfiguration | Where-Object { $_.IPAddress -ne $null } #| Select-Object DNSHostName,Description,IPAddress,IpSubnet,DefaultIPGateway,MACAddress,DNSServerSearchOrder | format-Table * -AutoSize
foreach ($info in $nwinfo) {#| Select-Object DNSHostName,Description,IPAddress,IpSubnet,DefaultIPGateway,MACAddress,DNSServerSearchOrder
$nwServerName = $INFO.DNSHostName
$nwDescrip = $INFO.Description
$nwIPADDR = $INFO.IPAddress
$nwSUBNET = $INFO.IpSubnet
$nwGateWay = $INFO.DefaultIPGateway
$nwMacADD = $INFO.MACAddress
$nwDNS = $INFO.DNSServerSearchOrder
# Server/CompName |NetworkCard | IPAdress | SubnetMask| Gateway | MAC Address| DNS |
Write-Host “$nwServerName | $nwDescrip | $nwIPADDR | $nwSUBNET | $nwGateWay | $nwMacADD | $nwDNS ” | ft * }
}
Thank you for your great work.
Subscribed to your blog.
You are Welcome Vycheslav 🙂
#
thanks
aman
Thank you very much for this great tool. Saved a lot of time. Best Regards from Switzerland
Thanks,
You are welcome, I am glad that you found it useful.
Regards
Aman
Hi, great script. I was wondering what command should I use to export results into csv. I tried to put export-csv filename.csv at the end, and it doesn’t work. Colld you please assist. Thank you.
HI Aman,
when I run the script I got no values returns so do you have an idea what might be the reason for that?
Thanks,
Peter