07-29-2016 12:46 PM
I have seen several topics that cover this but I am still not able to login to multiple domains. I have the xml file with the passwords, and I get logged into the domains just fine but when I issue a command such as get-ucsserver I get back an error:
Get-ucsserver : No UcsHandle specified and the Default Ucs list is empty.
I can't see where I am going wrong here. Please help!
Jerry
Solved! Go to Solution.
08-02-2016 09:12 PM
Hi Jerry,
To what I see from the error it looks like you are using Cisco UCS PowerTool Suite 2.x release and UCS Manager PowerTool 1.x on the same system so you are running in to these issues.
Can you please let us know if the above observation is correct?
What is the version of the PowerTool you are using?
Thanks,
Sumanth
07-31-2016 08:56 PM
Hi Jerry,
Can you please share how you are connecting to multiple domains?
Use this cmdlet before connecting to multiple UCS domains in your script.
Set-UcsPowerToolConfiguration -SupportMultipleDefaultUcs $true
Let us me know if this helps.
Thanks,
Sumanth
08-01-2016 09:30 AM
I am using the xml method, like so:
Connect-Ucs -Literalpath c:\path\to\file\domains.xml
If I do this from the command line, not in a script, and issue get-ucssession I see list of all the domains I am connected to. Then I issue get-ucsserver and I get:
PowerTool c:\scripts> Get-UcsServer
Get-UcsServer : No UcsHandle specified and the Default Ucs list is empty.
At line:1 char:1
+ Get-UcsServer
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-UcsServer], Exception
+ FullyQualifiedErrorId : System.Exception,Cisco.Ucsm.Cmdlets.GetUcsServer
I am confused as to why the commandlet is not seeing the list already there. I have tried this several ways, but all end with that error. If I just connect to a single domain the script runs just fine. This is already in my script:
Import-Module CiscoUcsPS
Set-UcsPowerToolConfiguration -SupportMultipleDefaultUcs $True #| out-null
08-02-2016 11:09 AM
Hi Jerry,
PowerTool uses a PS Session variable called DefaultUcs which will store all the UCS session handles. You need to set the variable from your script so that you can execute any PowerTool cmdlet without specifying session handle every time.
Connect-Ucs using XML file should automatically set the required variable if it is not getting set then you can try the below snippet.
$ucsDomains = Connect-Ucs -Literalpath c:\path\to\file\domains.xml
# Create an array of type UcsHandle by specifying the size of the array as no of UCS domains session handles you have already connected.
$ucsSessionHandles = New-Object -TypeName Cisco.Ucs.UcsHandle[] $ucsDomains.Count
# Copy the value of the sessions one by one to the array you have created above
for($i =0; $i -lt $ucsDomains.Count; $i++)
{
$ucsSessionHandles[$i] = $ucsDomains[$i]
}
# Set the DefaultUcs PS Session variable using the below statement.
$ExecutionContext.SessionState.PSVariable.Set("DefaultUcs", $ucsSessionHandles)
Once you have done this you will be able to run any PowerTool cmdlet without specifying the session handle.
For ex: Get-UcsServer
Note:
If you are using UCS PowerTool Suite 2.0.1 and above then use this line for initialising the $ucsSessionHandles
$ucsSessionHandles = New-Object -TypeName Cisco.Ucsm.UcsHandle[] $ucsDomains.Count
Let me know if you need further help on this.
Thanks,
Sumanth
08-02-2016 02:31 PM
No, I now get the same error I got in another attempt:
Get-UcsServer : Cannot bind parameter 'Ucs'. Cannot convert the "Cisco.Ucs.UcsHandle" value of type "Cisco.Ucs.UcsHandle" to type "Cisco.Ucsm.UcsHandle".
At C:\Users\cn105466\Scripts\t2.ps1:36 char:20
+ Get-ucsserver -Ucs $DefaultUcs | %{
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:), ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Cisco.Ucsm.Cmdlets.GetUcsServer
Many commands, such as GetUcsServerPool, have always worked, and query all domains. But GetUcsServer and GetUcsServerUnit do not. I wish better, or at least more detailed, documentation existed, I am sure it going to be something like the hash structure between those two objects is just slightly different or spells ServerName SrvName. What is odd is that all of the command that seem to work are listed in CiscoUcsPS.dll-help.xml, such as GetUcsServerPool. GetUcsServer is not, but as long as I keep to one domain everything works.
08-02-2016 09:12 PM
Hi Jerry,
To what I see from the error it looks like you are using Cisco UCS PowerTool Suite 2.x release and UCS Manager PowerTool 1.x on the same system so you are running in to these issues.
Can you please let us know if the above observation is correct?
What is the version of the PowerTool you are using?
Thanks,
Sumanth
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide