Export subnets from Meraki to phpIPAM
In order to populate phpIPAM I needed to export all subnets that was already present in Meraki Dashboard without type all information manually. I found PSMeraki module on Github which is a prerequisite for this script. The script creates a CSV that can be importet in to phpIPAM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$networks = Get-MrkNetwork
$subnets =@()
foreach ($network in $networks) {
foreach ($vlan in $network) {
$vlans = Get-MrkNetworkvlan -networkId $network.id
foreach ($vlan in $vlans){
if (!$vlan.subnet){
break
}
else{
$sub = Get-Subnet $vlan.subnet
$subnetname = $network.name + "_" + $vlan.name
[hashtable]$net = @{}
$net.add('VLAN',$vlan.id)
$net.add('Section','Company')
$net.add('Subnet',$sub.ipaddress)
$net.add('Mask',$sub.Maskbits)
$net.add('Domain',$network.name)
$net.add('Description',$subnetname)
$objVlan = New-Object -TypeName psobject -Property $net
$subnets += $objVlan
}
}
}
}
$subnets | Export-Csv -Path subnets.csv -Delimiter ","
This post is licensed under CC BY 4.0 by the author.