Amazon Cyber Monday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

PowerShell List All Devices on Network: 10 Ways

This guide covers 10 concrete PowerShell methods to list every device on your local network, from quick ARP-table scans to full Active Directory inventories. It’s written for IT admins, sysadmins, and power users who need accurate, scriptable network discovery without installing third-party tools. Each method includes real cmdlets, parameters, and output examples so you can copy, adapt, and run them immediately.

1. Get-NetNeighbor (ARP Cache)

The fastest way to see active devices is the ARP cache. Run Get-NetNeighbor -AddressFamily IPv4 | Where-Object {$_.State -eq 'Reachable'} to list IP and MAC addresses of devices your machine recently talked to. It’s built into Windows 8/Server 2012 and later, requires no admin rights, and returns results in under a second. The downside: it only shows devices your PC has communicated with, so it misses idle hosts. Use it as a first pass, then follow up with a ping sweep.

2. Ping Sweep with Test-Connection

To discover all live hosts on a subnet, script a ping sweep. Loop through IPs 1-254 with Test-Connection -Count 1 -Quiet and collect responses. A compact one-liner: 1..254 | ForEach-Object { if (Test-Connection -ComputerName "192.168.1.$_" -Count 1 -Quiet) { "192.168.1.$_" } }. This is reliable but slow (about 4 minutes for a /24). Speed it up by using -AsJob or parallel workflows. Combine with Resolve-DnsName to get hostnames for each responding IP.

3. Get-SmbShare and Get-SmbSession

If you’re on a Windows network with file sharing, SMB cmdlets reveal active clients. Get-SmbSession lists devices currently connected to your SMB shares, showing the client IP and username. Get-SmbShare shows shared folders, but not devices. To get a broader view, query each machine’s SMB service using Invoke-Command with admin credentials. This method is great for spotting unauthorized access but only works if SMB is enabled and firewalls allow it.

4. Get-WmiObject Win32_NetworkAdapterConfiguration

This legacy WMI class gives detailed NIC info for the local machine, not the whole network. However, you can use it remotely: Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName RemotePC returns IP, MAC, and gateway for that device. Pair it with a list of known IPs from a ping sweep to collect MAC addresses and DHCP lease info. It requires WMI access (port 135) and admin rights on the target. For modern systems, prefer Get-CimInstance.

5. Get-DnsClientCache

Your DNS cache holds recent name-to-IP mappings, which can reveal devices you’ve resolved. Run Get-DnsClientCache | Where-Object {$_.Type -eq 'A'} to list hostnames and IPs. It’s instant and requires no special permissions. The limitation: it only shows names your PC has queried, so it’s incomplete. But it’s a handy supplement to ARP, giving you hostnames for IPs you already know are active.

6. Get-NetTCPConnection (Active Connections)

For devices currently communicating with your machine, use Get-NetTCPConnection -State Established | Select-Object RemoteAddress, RemotePort. This shows live sessions—useful for spotting active clients or suspicious connections. Filter by local port to isolate specific services (e.g., port 445 for SMB). It’s instant, but only shows devices that have an open TCP connection to you, so idle devices are invisible. Combine with UDP queries for broader coverage.

7. Invoke-Command with Get-NetIPAddress

If you have admin credentials and WinRM enabled, you can query multiple remote machines directly. Use Invoke-Command -ComputerName (Get-Content servers.txt) -ScriptBlock { Get-NetIPAddress -AddressFamily IPv4 } to retrieve IP configs from many devices at once. This is the most accurate method for a managed fleet, as it returns the actual interface configuration from each host. Set up a trusted hosts list or use HTTPS for security. It’s slower due to WinRM overhead but gives authoritative data.

8. Get-ADComputer (Active Directory)

In a domain environment, Get-ADComputer -Filter * -Properties IPv4Address, OperatingSystem lists every computer account in AD with its last known IP and OS. This is the only method that shows offline devices too, as it reads the directory, not live network state. It requires the ActiveDirectory module (install via RSAT) and domain credentials. Sort by LastLogonDate to see which devices are actually active. Use -SearchBase to limit to a specific OU.

9. Get-NetworkSwitch via SNMP (using PowerShell)

For network hardware, you can query SNMP-enabled switches and routers directly. Use the SnmpSharpNet library (install via Install-Package SnmpSharpNet) to send GET requests for the ARP table (OID 1.3.6.1.2.1.4.22). This reveals the MAC-to-IP mapping on the switch, which is the most complete view of the LAN. It requires the SNMP community string (often ‘public’ on lab gear). This is advanced but gives you every device the switch knows about, including those not talking to your PC.

10. Write a Custom Scan with System.Net.NetworkInformation.Ping

For a reusable, parallel scanner, use .NET classes directly. The System.Net.NetworkInformation.Ping class is faster than Test-Connection because you can send multiple pings asynchronously. Example: create a list of ping objects, send them all, then collect replies. This method is highly customizable—you can add port checks, resolve hostnames, and output to CSV. It’s more code, but it’s the best balance of speed and control for a production script.

How to Choose

Pick your method based on three factors: scope, speed, and credentials. For a quick check of active devices on your own subnet, Get-NetNeighbor plus a ping sweep is enough. For a full inventory of a domain, use Get-ADComputer. If you need MAC addresses and have admin rights, use WMI/CIM remotely. If you’re scanning an unknown network, start with a ping sweep, then use ARP to get MACs. Always consider firewall rules—WinRM, WMI, and SNMP are often blocked. For large networks, parallelize your scans to avoid timeouts. Finally, remember that no single method reveals every device; combine two or three for best coverage.

Frequently Asked Questions

Q: Do I need admin rights to list devices? A: No for ARP, DNS cache, and ping sweeps. Yes for WMI remote queries and AD module access.

Q: How can I get hostnames for IPs found via ping? A: Use Resolve-DnsName <IP> or [System.Net.Dns]::GetHostEntry(<IP>). Note that many devices don’t have reverse DNS records.

Q: Why doesn’t my ping sweep show all devices? A: Many devices block ICMP (ping). Use ARP table after a broadcast or check firewall logs for more complete results.

Q: Can I list devices on a different subnet? A: Yes, if you have a route to it. Use a ping sweep on that subnet, but expect slow results if the network is large or firewalled.

Q: How do I export the list to a file? A: Pipe to Export-Csv devices.csv or Out-File devices.txt. For example: Get-NetNeighbor | Export-Csv -Path arp.csv.

Q: Is there a way to scan for devices running a specific service? A: Yes, use Test-NetConnection -ComputerName <IP> -Port <port> in a loop to check for open ports like 445 (SMB) or 3389 (RDP).

Final Thoughts

PowerShell gives you multiple ways to list network devices, each with trade-offs between speed, completeness, and access requirements. Start with the built-in cmdlets like Get-NetNeighbor for a quick snapshot, then move to ping sweeps and AD queries for deeper inventory. For a truly complete view, combine ARP, DNS, and SNMP data. These methods are scriptable, so you can automate regular scans and keep your network map up to date. With practice, you’ll be able to identify every device on your LAN in minutes—without installing a single third-party tool.

PowerShell List All Devices on Network: 10 Ways
Scroll to top