I have used a very short vbscript for the last few month in order to get some data out of the SMP agent interfaces, or to ascert certain (misbehaving) features.
Today it proved itself to be very handy when a customer of mine was challenged to get a NSE file into the SMP database. So I'm posting the vbscript code here with details on how to use it.
Here's the code used today, anonymised for public consumption:
Set xmlhttp = WScript.CreateObject("Microsoft.XMLHttp") url = "http://server_name.domain_name/Altiris/NS/Agent/PostEvent.aspx" xmlhttp.open "POST", url , False WScript.Echo "Sending request to the server... " xmlhttp.send "<?xml version='1.0'?><message><priority>0</priority></message>" Wscript.echo "Response = "& xmlhttp.responseText
As you can see it is short and to the point, but let's review it line by line:
Set xmlhttp = WScript.CreateObject("Microsoft.XMLHttp")
Here we setup an instance of the XMLHttp object thru COM. This is the object used by Internet Explorer to process AJAX requests. We'll use the object in order to send the request up to the server and handle the response back.
url = "http://server_name.domain_name/Altiris/NS/Agent/PostEvent.aspx"
This is the url we're going to interact with in this first sample. We'll discuss a few more in a minute or two ;-). The agent url's should be well known now, but if you are still unclear I can only recommand you check the aila2 documentation, as the tool is designed to analyse IIS log files in the Altiris context [1].
xmlhttp.open "POST", url , False
We open the connection here, indicating that we will be post data up to the server (which is the prefered method for handling data exchange since the 7.o times). The arguments provided in the function call are the http method, the url to fetch and a boolean value to indicate whether the call should be made asynchronously or not. In our case we want to wait for the response before moving on to the next line of code. You can also specify a user name and password to connect to the url as described in Microsoft documentation [2].
WScript.Echo "Sending request to the server... "
This line could be optional, but it's good practice in my opinion to provide some feedback to the user on interactive programs.
xmlhttp.send "<?xml version='1.0'?><message><priority>0</priority></message>"
This is the line that actually make the http request to the server. The posted data is included in double quotes. Not that this is note a valid NSE file but it should be uploaded to the server fine, albeit it won't be processed as it is empty (of interesting data).
Wscript.echo "Response = "& xmlhttp.responseText
This final line waits for the responses to be received by the XMLHttp before printing out the outcome.
[1] https://www-secure.symantec.com/connect/search/apachesolr_search/aila2
[2] http://msdn.microsoft.com/en-us/library/ms757849%28v=vs.85%29.aspx