Problem exporting to csv

by Mar 25, 2015

I'm incredibly new to PowerShell, and thought I could piece together what I'm trying to do, but I'm stuck on something I thought would be fairly simple.

What I'm trying to do is audit a /24 subnet and get MAC address and hostname info from all the IPs.

I've got a basic script that will run a lookup on the entire /24 and export to a csv file with IP/hostname. The problem I'm having is getting the MAC address in there.

I attempted to start by exporting arp -a to csv, but I just get a file with one column of 2 random numbers. I'm not sure what it is but it's not what I want.

I tried to mess around with Format-Table but I think that the results from arp -a don't have any column headers so I can't name them.

Any idea what I'm doing wrong or how I could do this better?