How to Get Computername and Guid in Workflow
There's been a few post about retrieving host computername in a Workflow. Here's how I do it:
A little javascript to access the Altiris.SWRAgentUtils which - as I understand it - is used by the Softwareportal (http://<ns-server>/Altiris/SWD/SoftwarePortal.aspx)
I have a form with two textboxes named txt1 and txt2 ( to name a control 'Edit Component -> Functionality tab', check 'Specify Control ID' and type Control ID below)
Add the following code to the form: 'Edit form -> Behavior -tab -> Script - click the elipse(...):
function getPCinfo(){
var objAltiris = new ActiveXObject("Altiris.SWRAgentUtils");
var PCinfo = objAltiris.getMachineInfo();
var PCname = PCinfo.MachineName;
var PCguid = PCinfo.MachineGuid;
document.getElementById('txt1').value= PCname;
document.getElementById('txt2').value= PCguid;
}
In the Body Custom Events click Add -> AttrubutesKeyValuePair
In the event-dropdown choose 'onload' and in the Eventhandler type:
getPCinfo()
You're now set to go - click OK and test away.
I'm no javascript-wiz so the script may not work in non-IE enviroments.
Comments
Thanks for the post
Thanks for the post claus66,
I'm working on doing exactly this, but I'm fairly new to the product and would appreciate as much information as possible. I see that you are editing a component in the screen shots but what component are you editing? Also, how do you tie this into a variable?
Hi Ranger The textboxes both
Hi Ranger
The textboxes both have Outputnames - without an Outputname you can't add the textbox to your form.
These Outputnames will be the variables that can be accessed later in the workflow.
The first screenshot is from one of the Textboxcomponent (to access the Edit Component dialog just double-click the textbox ).
The next two screenshots are both from the webform-component (double-click an empty spot on your form)
Hope it helps
Thanks claus66
Thanks for the reply,
I've been meaning to reply back. I made those changed and everything is working! Thanks again for the post.
Top of the Morning Great
Top of the Morning
Great stuff....works like a charm...much thanks
A simple variation using WMI
If you don't have Altiris.SWRAgentUtils available, you can also get the computer name directly via WMI. Follow claus66's suggestions exactly, except replace the Script with the following:
function getPCinfo(){
var ax = new ActiveXObject("WScript.Network");
document.getElementById('txt1').value=(ax.ComputerName);
}
Important note: any time you are running JavaScript as a client-side script, the script will only work if the browser settings allow for it. The above script only worked for me once I backed down my IE security options in Tools / Internet Options / Security (I basically enabled several items in there that were previously disabled). The caveat therefore is your end-users will need to have similarly accomodative browser settings, or else the script will not run. So your level of control over the end-user's browser security is paramount to success, which is why client-side scripting is better off avoided if possible.
Would you like to reply?
Login or Register to post your comment.