« Back to Microsoft Discussions

What's the command to assign a Service Profile to a Blade?

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
For some reason, I can't determine exacly how to take the service profiles I have and attach/assign them to blades or server pools. Documentation isn't guiding me, and I can't seem to guess. 

Hey John -

Thanks for the post. We've scoped a cmdlet called set-spassociation but it didn't make this release. In the meantime, you can use the invoke-xmlcommand cmdlet. That will essentially let you do anything in UCSM via PowerShell - even if we haven't written a specific cmdlet for it. Here's an example of how to do what you're asking:

Assuming you're already connected to a UCS cluster via PowerShell (connect-ucsm), the command would look like this:

PS>invoke-xmlcommand -xmlstringlist "<configConfMo inHierarchical="no"><inConfig><lsServer dn="org-root/ls-HyperV-Host2"><lsBinding pnDn="sys/chassis-1/blade-5" rn="pn" /></lsServer></inConfig></configConfMo>"

You'll obviously want to substitute the service profile name (ls-HyperV-Host2 in my example --- remember to keep the ls- as a prefix to your 'english' SP name) and destination server DN (I used sys/chassis-1/blade-5).

If that's too ugly (which I'd understand), you can try plopping the XML into a text file and calling it via PoSh -- same cmdlet, just use the '-filename' parameter and specify the path to the XML content.

Hope that helps!!

Josh

Most of my UCS powershell scripts relies on custom functions that would be too much and haven't been tested enough to post here. I am in the process of trying to reformat them to utilize the UCS cmdlets. Here is a section of code that I have used and works. It inputs from a CSV that has headers; Servers,ChassisID,BladeID. Servers is the name of the service profile, the other two are self explanatory...I hope. I utilize the Get-Org cmdlet to save having to input the DN myself incase it was a sub-sub-organization. Note here, I tried using Get-Org with just an org name and the -recursive option and it didn't return anything. Not sure why so I still have to play with but I have only had these for a couple days.

A comment on Joshua's code. I don't think that will work because he doesn't have all the extra quotations escaped with another set of quotes. So to take just a bit of that line the first quote starts the string but then to the cmdlet that string stops after the first equal sign and no is a separate item and so on. Again this is an assumption and I haven't tested it but from my understanding that line won't work as you would think. I would suggest something like my line below where each quote inside the XML is escaped with another quote. Just food for thought as we begin to explore the use of Invoke-Xmlcommand.

 1
 2###### INPUT files  ######
 3#  $Servers CSV should have headers for Server,ChassisID,BladeID
 4$Servers = Import-Csv -Path "./inputs/STC21717UCS201.csv"
 5$org = Get-Org -Org "root/ORGNAME"
 6foreach ($server in $Servers)
 7{
 8    $xmlcmd = "<configConfMos cookie=""$($CurrentUCSMInstance.Cookie)"" inHierarchical=""false""><inConfigs><pair key=""$($org.dn)/""><lsServer dn=""$($org.dn)/ls-$($server.server)""><lsBinding pnDn=""sys/chassis-$($server.chassisID)/blade-$($server.BladeID)"" /></lsServer></pair></inConfigs></configConfMos>"
 9    Invoke-XmlCommand -XMLStringList $xmlcmd
10}

Kevin -

Good point - the text I pasted was from my text file (where the quotes won't escape). I should have replaced those with single quotes within the overall XML string. That works well.

Also - I noticed that you included the cookie in your string - once you've established the connection to UCS, that connection object (and the cookie it holds) gets referenced in subsequent calls from the toolkit. So you don't need to reference the hand....

Thanks!
Josh

Thanks for the info Josh. I was wondering if that would be handled or not but I figured better safe than sorry. That is good to know going forward.

Thanks