Michigan Endpoint Management User Group

 View Only
Expand all | Collapse all

Doing a Custom Inventory based on the Command script option.

  • 1.  Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 10:17 AM

    I've got a custom data class and I need to run a Command Script to get the results.  I'm running a very complicated Dsget command that is returning only a single value and is becoming almost impossible to run within a VBS. 

    Can anyone tell me how to kick off a custom inventory using the Command Script that returns a single value and kicks off the inventory process so it creates the NSE file?

    There does not seem to be any examples on connect for this process.  I've looked at HOWTO50026 and various other connected to this howto and yet cant find any that involve command script. 

    Help.

     



  • 2.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 10:47 AM

    Why can't you use VB or Powershell to obtain the data as well as create the NSE?

    If gathering the data is only possible via a BAT file, then have your BAT write the value to either an INI file or the registry, and then use a VB custom inventory scan to gather the data from that location.

    You could either have the BAT call the VB, or create a BAT & a VB run script command, and then add them both to a Managed Software Delivery policy.



  • 3.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 10:59 AM

    I'm having difficulty with the vb command because its a DSGet command with is long and complicated and when I try and use the objshell.run option on the command it simply runs it and moves on before it returns a value.

    dim countCode
    Set countCode = CreateObject("WScript.Shell")
    strErrorCode = objShell.Run "cmd dsget group "CN=Projectpool,OU=MS Project,OU=Application Groups,OU=Groups,OU=CORP,DC=intra,DC=mydom,DC=com" -members -expand -c 2>nul| dsget user -display -disabled -office"
    'WScript.Echo countCode

     

    I've tried combos of ( and " to get the objShell.run command to work but I keep getting end of line errors or syntax.  I also tried assigning variables to the string of requests and that kind of work but only returned a value of 0 too quickly. 

    I dont want to call a bat file because for policy reasons, and secondly the Documentation notes say there are many options when programing a custom inventory yet the only option documented are VBS.  Since Symantec says I can use Command script I want to know who to do Command script.

    that is unless I can get the VBS script to work.

     



  • 4.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 11:14 AM

    Do you intedn to run this script on each client or just on the SMP?

    If the latter, wouldnt using either an AD Import rule or an ADSI query filter be easier?



  • 5.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 11:52 AM

    I'm using it as custom inventory on one computer/ server (target may change from one server to another on any given month) for Inventory.  to return a count # of users in an AD group - the machines and other groups in order to attach that # to the Compliance report of Cals being used for a server product.

     



  • 6.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 12:06 PM

    So the cals are associated with the server you are running the custom inventory on then?



  • 7.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 12:52 PM

    No they are not.  As I posted in my original question, I have a DSget command that returns a value.  I've not found a way to get the returned value from VBS. 



  • 8.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 01:49 PM

    OK.  I am just trying to understand why you need to perform this action via custom inventory.

    Where does your CAL compliance report get its data from?  The Symantec_CMDB database or somewhere else?



  • 9.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 01:57 PM

    SK, I really appreciate your attention and efforts.  But you are going off on too many directions.  My question was how to do a custom inventory from Command script.  Thats it.  Not how to read cals, or read AD.  I have the solution for reading that was given to me.  So I need to do a custom inventory task based on Command script as documented in Symantec's release notes. For example lets say it has nothing to do with cals.  It might have everything to do with what the machine is reporting as date.  Yes I can do that in vb as well, but if my boss tells me to use Command Script because Symantec says "doing custome inventory can be done in command script" I need to find out how that is done. 

    Again that you for the assistance but you are going in directions that I cant go.

     



  • 10.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 20, 2014 05:01 PM

    The short answer is, I've never done a custom inventory with a command script so I'm not sure how you would do that. 

    My recommendation is that you use VBS to get the information you need using AD libraries / LDAP calls instead of using DSGET. 



  • 11.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 21, 2014 05:38 AM

    Can anyone tell me how to kick off a custom inventory using the Command Script that returns a single value and kicks off the inventory process so it creates the NSE file?

    Just to be clear, there are no Symantec documents describing how to create custom inventory Tasks in any other language than VBS. The sample is the only one and it is in VBS and provided with a default NS7+ install. http://www.symantec.com/docs/HOWTO50036

    To create the NSE you require a language that can access the Altiris Component Object Model to invoke the methods for constructing the XML and calling NSE.send. If you can construct an array then re format the COM process that constructs the XML, finds the SMP then copy the file to the Event Queue, then i'm sure you can do it in DOS. It is not expected that you do since the COM was provided to do that for you.

    The last time we used DOS for starting custom inventory was for calling the command line in NS6.0 which eventually just ran a different language anyway. I've done it with Autoit, others have examples with other languages, but DOS 7 is a no go. Additionally, DOS is is a language that runs every line and moves on to the next when complete, there is no runwait unless you start pinging yourself or some other workaround.

    Hopefully the confusion stems from the legacy instructions.

    I'm having difficulty with the vb command because its a DSGet command with is long and complicated and when I try and use the objshell.run option on the command it simply runs it and moves on before it returns a value.

    Run Method (Windows Script Host)

    http://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.84).aspx

    You need to change the objShell.Run line to have the additional parameter for the bWaitOnReturn value which is a Boolean

     object 
                          .Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 

    As a side, calling command lines from VBS is usually fraught for the reason you first suggested and they start popups, user interaction and so on. I would recommend studying the DSget equivalents. http://www.rlmueller.net/ADOSearchTips.htm is a good starting place.



  • 12.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 21, 2014 05:56 AM

    Just thinking how close I can get to your desired solution so you don't get the feeling this is all negative. Use the basis of the VB sample provided, call a batch file from the start. Batch file does your dsget, pipes it into a text file, next line back at the VBS reads the contents of the test file into a variable like "myvariable", write the variable as a line in the VB like:

    ...

    dim objDataRow

    set objDataRow = objDataclass.AddRow

    objDataRow.SetField 0, myvariable

    nse.send

    Just seems to be messy rather than using VB natively, plus VB requires little more than copy/paste from the internet these days there are so many solutions. The other issue with this is you get the entire DSget as one entry so its nasty looking in your database and not split into meaningful chunks. Most of the issue with the results is how to chop them up...but i'm drifting off scope here...

     



  • 13.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 25, 2014 01:16 PM
    Second the use of the wait parameter on shell.run(), but also agree this isn't the best way to get this data into your cmdb. You'd be better if using an ad import rule with custom filters (to strip out the disabled users, if I'm reading your command right), then you can pull that value directly from the database, and not depend on a particular system running it. Likely the command isn't working since you're trying to execute dsget against the domain using effectively the local system account. Did you try setting the command to run as the logged on user, or a specific domain user? Regardless, A.D.import probably a better route.


  • 14.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 27, 2014 09:17 AM

    AD import is probably the best suggestion I've gotten so far and we are looking into that.  It does not give me exactly what I need but can work with it I think.

    However the point of this exercise was to do inventory based on COMMAND SCRIPT, why?  because Symantec says you can.  I want someone to prove it.

    thats all I want Symance to prove they can do something they wrote in their documentation or remove it.

     



  • 15.  RE: Doing a Custom Inventory based on the Command script option.

    Posted Jan 27, 2014 09:38 AM

    You can add custom sytaxes to the AD import rule; however, if you could also create ADSI filters that would do the same thing; however, they would be updated at the same frequency as all other normal filters, instead of waiting on the next scheduled AD import to run. 

    https://www-secure.symantec.com/connect/articles/how-create-active-directory-filters-without-using-ad-import-rule

     

    I understand your point in wanting to see such a custom inventory example, so hopefully someone from the Inventory team will either provide one or remove this scripting option from the Inventory documentation.