PowerShell - Get Win32NetworkAdapterConfiguration from text list
- Jon Boyette
- Jan 11, 2022
- 1 min read
Updated: Feb 10, 2022
Save as a name.ps1 and populate c:\temp\servers/txt, outputs server/computer information to screen including: IPAddress, Description, DNSServerSearchOrder, WINSPrimaryServer, WINSSecondaryServer, DNSDomain, DefaultIPGateway, MACAddress
$colComputers = get-content C:\temp\servers.txt
foreach ($strComputer in $colComputers)
{
# PowerShell cmdlet to interrogate the Network Adapter
$colItems = get-wmiobject -class "Win32_NetworkAdapterConfiguration" `
-computername $strComputer | Where{$_.IpEnabled -Match "True"}
write-host --Begin-Network-Details-For--> $strComputer
foreach ($objItem in $colItems) {
write-host ""
write-host "IPAddress : " $objItem.IPAddress
Write-Host "Description : " $objItem.Description
write-host "DNS Servers in Order : " $objItem.DNSServerSearchOrder
Write-host "WINS Server Primary : " $objItem.WINSPrimaryServer
Write-Host "WINS Server Secondary : " $objItem.WINSSecondaryServer
Write-Host "DNSDomain : " $objItem.DNSDomain
Write-Host "DefaultIPGateway : " $objItem.DefaultIPGateway
write-host "MAC Address : " $objItem.MACAddress
write-host ""
write-host "--End-Network-Details-For-> $strComputer"
write-host ""
}
}
Comments