I'm currently trying to create a easy to read document containing all devices on are network (3k+). Currently I have all my data within nested hashtables like so:
$devices = @{"hostname" = @{"Mac Address" = @{"IP Address" = "True or False"}}}
It stores the hostname of the device in $devices. Within the $hostname there is a hashtable containing all MAC addresses associated with that hostname. Within the MAC address there is a hashtable containing all IPs associated with that MAC address.
I've already created part of the script that creates the hashtable and stores the data. I have ran into a road block with exporting the data into a CSV that can be read in Excel with the format of.
Hostname, Mac Address, IP Address
server1, MM.MM.MM.SS.SS.SS , 1.1.1.1
1.1.1.2
MM.MM.MN.SS.SS.SA , 1.1.1.3
server2, MM.MM.MB.SS.SS.ST , 1.2.3.1
, 1.5.2.1
and so on.
Edit:
foreach ($hostname in $devices.Keys) {
echo $hostname
foreach ($Macs in $devices.$hostname.Keys) {
echo $Macs
foreach ($IPs in $devices.$hostname.$Macs.Keys) {
echo $IPs
}
}
}