« Back to Microsoft Discussions

Creating VLAN using invoke command

Combination View Flat View Tree View
Threads [ Previous | Next ]
Hi team
 
First of all,great work with the powershell toolkit.
Even though u guys have created a command for creating vlan,i was curious to work it out using the invoke command.
 
below is the command that i used to create a vlan TEST with ID-122 in my powershell script:
 
invoke-xmlcommand -xmlstringlist "<configConfMos inHierarchical='no'><inConfigs><fabricVlan dn='fabric/lan/net-TEST' id='122' name='TEST'</fabricVlan></inConfigs></configConfMos>"
 
But when i execute this command i get the following error:
 
 
Invoke-XmlCommand : Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 1, position 129.
At C:\ucs\createvlan.ps1:7 char:18
+ invoke-xmlcommand <<<<  -xmlstringlist "<configConfMos inHierarchical='no'><inConfigs><fabricVlan defaultNet='no' dn=
'fabric/lan/A/net-TEST' id='122' name='TEST' </fabricVlan></inConfigs></configConfMos>"
    + CategoryInfo          : NotSpecified: ( [Invoke-XmlCommand], XmlException
    + FullyQualifiedErrorId : System.Xml.XmlException,Cisco.UCSCmdlet.Commands.Operations.InvokeXmlCommand






Can you please suggest how to correct it.






Thanks


Jayant Anand

Hey Jayant,

You made two mistakes that I see. First you are missing a > ending your <fabricVlan> tag. Secondly, by my understanding if you use "configConfMos" instead of "configConfMo" then you need to use the <pair> tags. I have two working examples below:

invoke-xmlcommand -xmlstringlist "<configConfMo inHierarchical='no'><inConfig><fabricVlan dn='fabric/lan/net-TEST2' id='2' name='TEST2'></fabricVlan></inConfig></configConfMo>"

or if you use configConfMos:

invoke-xmlcommand -xmlstringlist "<configConfMos inHierarchical='no'><inConfigs><pair key='fabric/lan/'><fabricVlan dn='fabric/lan/net-TEST2' id='2' name='TEST2'></fabricVlan></pair></inConfigs></configConfMos>"


If any one has anything to say I am interested to hear more on the differences. The second example is how I created VLANs before the toolkit.

Maniacmurphy
Community Supporter