We want to automate the execution of scripts on our devices and thus I'm wondering if it's possible to drive the Network Configuration Manager with an API or what have you?
Thanks
Pretty close. The body for an Invoke call is always an array. For Cirrus.ConfigArchive/Execute, the first argument is also an array. The "transfer ID" string uses the NCM NodeID (which is a GUID), not the integer NodeID, and the username segment is not wrapped in {braces} - that's just powershell string interpolation syntax.
So this command: Invoke-SwisVerb $swis Cirrus.ConfigArchive Execute @($nodeIdList, $script, $username)
Turns into this HTTP request:
POST /SolarWinds/InformationService/v3/Json/Invoke/Cirrus.ConfigArchive/Execute
[
["44550400-8415-4209-b78e-c5596cdfe086"],
"show clock",
"admin"
]
And the transfer id string would be "{44550400-8415-4209-b78e-c5596cdfe086}:admin:ExecuteScript"
I use a Chrome extension called "postman" to test REST APIs. I attached example requests to this reply. If you are having trouble with these calls, you might find it helpful to install postman and load up this file.
Yes, you can tell NCM to execute a script on a device (or many devices). In the Samples\PowerShell directory, the NCM.ExecuteScript.ps1 script should get you started. Let me know if you need any other details.
Great! Now, lets start with my favorite question; Can this be done with C# / REST call(s) ?
You bet. SWIS only has six basic operations: Query, Invoke, Create, Read, Update, Delete. All of the interfaces (REST, SOAP, and PowerShell) support all of these operations. Anything you can do with one, you can do with the others. Only the syntax will be different.
Excellent.
I can see that most of it is just queries, of which I've done enough to be confident that I can translate the PS into C#. However, here are the parts I'm going to run by you to make sure my assumptions are correct.
I assume this:Invoke-SwisVerb $swis Cirrus.ConfigArchive Execute @($nodeIdList, $script, $username) | Out-Null
Will translate to something like this:Url: */v3/json/Execute/Cirrus.Nodes/Cirrus.ConfigArchive, yes?
And the body data will be something like:{ [GuidNodeID(s) e.g. "<guid>", "<guid>" ], "script_Text", "<username>" }
Correct? Or should the whole be an array as well as the Guids?[ [ "<guid>", "<guid>" ], "script_Text", "<username>" ]
Then there's this line.$transferID = "{$nodeId}:${username}:ExecuteScript"
I assume it will translate to something like this?string transferID = "{340}:{userScott}:ExecuteScript"