I have approximately 2,000 .csv files from an IPAM subnet export, which generates a spreadsheet per subnet. I know the IPAM API has the ability to Create subnets, with the 'New-SwisObject' command, however, I don't have enough PowerShell experience to know how to put all the pieces together.
My idea is to Target the folder the subnet documents are in (C:\ips) and populate the Address, FriendlyName, and CIDR Property variables in the script, from each file the folders. The Addresses, and CIDR values would come from the Excel columns, "Subnet Address", and "Subnet CIDR", and the FriendlyName would be the name of the file itself.
However, what i'm not sure is, how can i say in the script that the address, friendlyname variables, and cidr are in each of the of the document , and how does the foreach statement work to go through each item in the folder?
Address= variable comes from Subnet Address column in csv
FriendlyName= variable comes from the file name of the csv
CIDR= variable comes from the Subnet CIDR of the csv
Here's what i have so far, but it's just a start.
$folder = get-childitem \ips
foreach ($file in $folder)
{
New-SwisObject $swis -EntityType 'IPAM.Subnet' -Properties @{Address='$subnet_Address'; FriendlyName='$filename of csv'; CIDR='24';}
}
I feel like this can't be that hard, i just don't know how to use PowerShell well enough to get all the pieces working together, or even if this is the right direction to go down. It's unrealistic to do all these manually, and i understand that any custom entries we had entered before would be lost, as we're not doing a full Subnet Import via a csv, but recreating the Subnet by referencing some data in the .csv.
Thoughts?
Thanks!