Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
So I read John McDonough's blog post Launch UCS KVM from a script and naturally set out to create a powershell script to do so because it sounded like a cool script. Lately I have been trying to make all my UCS scripts use 100% Cisco provided cmdlets rather than some of my custom ones so I have to use a lot of Invoke-XmlCommand. The final part was to get the authentication token from the UCS. Sending the command over UCS returns null. No errors or anything written to console but taking the exact same XML string and sending it to the UCS over a custom function to send http posts to the UCS returns values. I have tried this with the two cookie attributes added in to the Invoke cmdlet and without them and with any combo of one or the othere. Any idea why the Invoke-XmlCommand doesn't do anything? Is there something different about the method that doesn't work with Invoke-XmlCommand?
 
 
 
$Token = Invoke-XmlCommand "<aaaGetNComputeAuthTokenByDn cookie=""$($CurrentUCSMInstance.cookie)"" inCookie=""$($CurrentUCSMInstance.cookie)"" inDn=""$($SP.pnDn)"" inNumberOf=""2""></aaaGetNComputeAuthTokenByDn>"

Thanks,
Kevin

Further examples. I was attempting to use Invoke-XmlCommand to create LDAP Providers. I run the command with Invoke-XmlCommand and got no errors or output. It just acted as if nothing happened. I ran it with my custom push and got back an error message saying the filter was wrong:

1Invoke-XmlCommand "<configConfMo inHierarchical=""true""><inConfig><aaaLdapProvider basedn='DC=DOMAIN,DC=LOCAL' rootdn=CN=OU,DC=DOMAIN,DC=LOCAL' filter='sAMAccountName=$userid' name='x.x.x.x'><aaaLdapGroupRule authorization='enable' rn='ldapgroup-rule' targetAttr='memberOf' traversal='non-recursive'/></aaaLdapProvider></inConfig></configConfMo>"


1Push-HTTPPostCommand -target $CurrentUCSMInstance.UcsUri -post "<configConfMo cookie=""$($CurrentUCSMInstance.cookie)"" inHierarchical=""true""><inConfig><aaaLdapProvider basedn='DC=DOMAIN,DC=LOCAL' rootdn='CN=OU,DC=DOMAIN,DC=LOCAL' filter='sAMAccountName=`$userid' name='x.x.x.x'><aaaLdapGroupRule authorization='enable' rn='ldapgroup-rule'  targetAttr='memberOf' traversal='non-recursive'/></aaaLdapProvider></inConfig></configConfMo>"
2
3<configConfMo dn="" cookie="1312984644/dd2c702c-8059-4354-ae4d-2943681c91c4" response="yes" errorCode="101" invocationResult="unidentified-fail" errorDescr="Incorrect search filter format for provider 10.140.72.135"> </configConfMo>


So Invoke-XmlCommand doesn't report all errors returned from the UCS? Luckily using the error returned from my custom function I was able to investigate my string and see that PowerShell was replacing $userid since it saw it as a variable. Once I escaped the $ with a back tick I was able to send the command Invoke-XmlCommand.