What It Does
The script is read-only and never leaves the network this PC is plugged into. It looks at the IPv4 network of the adapter that holds the default gateway, or at the network you name in Subnet, which must lie inside a network this PC is directly attached to; anything else is refused. Subnet must be between /22 and /30. A PC with no active IPv4 connection, or with no default gateway and no Subnet, is skipped.
Without a sweep it lists the neighbor table, the devices this PC has talked to recently, so a quiet device can be missing. With Sweep=true it pings each usable address of the subnet once, except this PC, with a one second wait, 64 at a time, and refuses a network bigger than /22, which is 1022 addresses. A device that blocks ping still shows up if it answers ARP. A sweep takes a few seconds on a /24 and up to a minute on a /22.
Host names come from a reverse DNS lookup, on by default and turned off with ResolveNames=false; many devices have none and the column stays blank. Each row says where it came from: This PC, Ping reply and neighbor table, Ping reply, or Neighbor table only. The OuiPrefix column is the first three bytes of the MAC address, which identify the maker in the public IEEE list. The script ships no maker table and invents no vendor names, so look the prefix up when you need it. A MAC address whose second digit is 2, 6, A or E is private (randomized), common on phones, and its prefix names nobody.
This PC is listed too when its address is inside the selected subnet, and the answer counts the other devices and how many have no host name. It scans no ports and does not say what a device is.
Before You Run It
- Run it once without a sweep, then with Sweep=true, and compare. The neighbor table alone misses quiet devices.
- Run it from a PC on the network you want to list. It only sees the network the PC is attached to.
- On a network bigger than /22, set Subnet to a piece of it, such as a /24, to sweep it.
- Look MAC prefixes up in the public IEEE list yourself. A randomized MAC has no maker to find.
Type and Risk
- Type: Report. It collects facts into a table and never alerts. It exits 0, or 2 when it could not run.
- Risk: Low. It reads and changes nothing.
- Restart: It never restarts the machine.
- Typical run: 5 to 60 seconds.
- Example answer: "Found 13 other device(s) on 192.168.1.0/24 (ping sweep and neighbor table); 5 without a host name"
- Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.
Inputs
Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.
- Subnet: The network to list, as CIDR, for example 192.168.1.0/24. Between /22 and /30 and inside a network this PC is attached to. Default empty = the network of the default gateway.
- Sweep: true pings every address of the subnet first. Default false (neighbor table only).
- ResolveNames: true looks up each device's host name. Default true.
Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.