Importing UCS VLANs

I’ve had to deal with two UCS systems recently, ensuring that the configuration matches on them both, most of which I was happy to go through by hand. But the long list of VLANs was another story. I could see that they can be exported, but I couldn’t find an import ability. So, a quick search later, I found this webpage: http://www.mennodeliege.nl/cisco-ucs-powershell-toolkit-vlan but is very nearly what I’m after, but we need to make a little modification.

 This is because the VLANs are exported in the following format:

ucs-vlan-csv

So we must adjust the powershell to take account of the format of the Name field (where the name always comes after the first “-”). This is what it looks like:

1
2
3
4
$vlancsv = import-csv "filename"
foreach ($row in $vlancsv) { 
    add-ucsvlan -id $row.ID -Name ($row.Name.SubString($row.Name.IndexOf("-") + 1)) -Sharing none -LanCloud (Get-UcsLanCloud) 
}

This does print out the details of each VLAN once it has been added. Adding a “| out-null” at the end of the line in the foreach loop should fix that if you want it to be nice and tidy.

Built with Hugo
Theme Stack designed by Jimmy