Client Management Suite

 View Only
Expand all | Collapse all

Custom Inventory Samples for NS6

  • 1.  Custom Inventory Samples for NS6

    Posted Jun 18, 2010 11:24 AM
    It used to be that there was a location to download some sample custom inventory scripts.  Does anyone remember where that would be located?  I can't seem to find it.

    Specifically I'm looking for one that might help me build a custom inventory to get the size of the My Documents folder on workstations.


  • 2.  RE: Custom Inventory Samples for NS6



  • 3.  RE: Custom Inventory Samples for NS6

    Posted Jun 18, 2010 01:32 PM
    Here's an ns7 version of a vbscript to do that very thing. It retrieves the folder size of each folder inside c:\documents and settings.

    I haven't added it to the above kb, yet.


    ''' Altiris Stuff
    'Create instance of Altiris NSE component
    dim nse
    set nse = WScript.CreateObject ("Altiris.AeXNSEvent")
    ' Set the header data of the NSE.  Please don't modify this GUID
    nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    nse.Priority = 1
    dim objDCInstance
    set objDCInstance = nse.AddDataClass ("cust_user_profile")
    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)
    ''' End of Altiris Stuff

    ' Create a filesystem object for the 'documents and settings' folder, then
    ' loop thru each subdirectory and get it's name, etc.
    set fs = CreateObject("Scripting.FileSystemObject")
    set folder = fs.GetFolder("C:\Documents and Settings")
    For each item in folder.SubFolders
        Set subF = CreateObject("Scripting.FileSystemObject")
        set subFolder = subF.GetFolder(item.path)
        Wscript.echo "folder.Name=" & subFolder.Name
        Wscript.echo "folder.Path=" & subFolder.Path
        Wscript.echo "folder.Size=" & subFolder.Size
       
        'Add a new row
        dim objDataRow
        set objDataRow = objDataClass.AddRow
        'Set columns
        objDataRow.SetField 0,  subFolder.Name
        objDataRow.SetField 1,  subFolder.Path
        objDataRow.SetField 2,  subFolder.Size
    Next       
    ''' Altiris Stuff
    ' Send the NSE data to the NS server
    nse.SendQueued
    ''' End of Altiris Stuff
    ''' End of vbscript main logic
    '********************************************************************************
    '* This vbscript gets user profile sizes
    '* Date Created: May 18, 2010
    '********************************************************************************


  • 4.  RE: Custom Inventory Samples for NS6

    Posted Dec 15, 2010 03:33 PM

    I have tried testing this script and it's erroring out, saying "Could not create object named "Altiris.AeXNSEvent".  Any idea on this?



  • 5.  RE: Custom Inventory Samples for NS6

    Posted Dec 15, 2010 03:51 PM


  • 6.  RE: Custom Inventory Samples for NS6

    Posted Dec 15, 2010 04:23 PM

    It is and I got it addressed using the 64-bit launch process checkbox.  Now there is an error on the line where it is trying to pull the folder size:

       objDataRow.SetField 2,  subFolder.Size 


  • 7.  RE: Custom Inventory Samples for NS6

    Posted Dec 15, 2010 04:32 PM

    I PM'd dougj.  Perhaps he'll stop by.  *crosses fingers*  I'm not a script writer, just a script scavenger.



  • 8.  RE: Custom Inventory Samples for NS6

    Posted Dec 16, 2010 02:48 PM

    I have tried both scripts Doug wrote for this (the other one is in the samples in the kb article noted above) and they are both getting permission denied errors.  I tried running with logged in user rights and still got the error as well.



  • 9.  RE: Custom Inventory Samples for NS6

    Posted Dec 16, 2010 03:35 PM

    Is the user that is logged in part of the machine Administrators group? If not this will cause an issue as the user will not permissions to other users folders under documents and settings.

     

    Larry



  • 10.  RE: Custom Inventory Samples for NS6

    Posted Dec 16, 2010 03:37 PM

    Yes, I was testing on my machine and I am logged in as a local Administrator.  It also failed using Altiris Agent credentials.

    I am assuming this script should work regardless of whether it is Windows XP or 7.  I changed the folder path to c:\Users from C:\Documents and Settings.



  • 11.  RE: Custom Inventory Samples for NS6

    Posted Dec 16, 2010 03:50 PM

    Copy this into notepad and save it as test_dir.vbs and run it via the cmd line like cscript test_dir.vbs and see if you still have issues in XP. As for Win7 I think the issue might be a AUC issue? You can comment out the XP line (put a ' in front of the line) and uncomment the Win7 line (remove ' in front of line) and run it on Win7 machine to see what happens. Basically the script is going to pass over the All Users folder.

     

    set fs = CreateObject("Scripting.FileSystemObject")
    Set folder = fs.GetFolder("C:\Documents and Settings") 'For XP
    'set folder = fs.GetFolder("C:\User") 'For Win7
    For each item in folder.SubFolders
        Set subF = CreateObject("Scripting.FileSystemObject")
        set subFolder = subF.GetFolder(item.path)
         If InStr(subFolder.Name,"All Users") = 0 then
          Wscript.echo "folder.Name=" & subFolder.Name
          Wscript.echo "folder.Path=" & subFolder.Path
          Wscript.echo "folder.Size=" & subFolder.Size
      End If
    Next

     

    Larry



  • 12.  RE: Custom Inventory Samples for NS6

    Posted Dec 16, 2010 04:39 PM

    Thanks for the assistance.

    Your test script and the script posted in this thread are both working in XP, although no data was sent to the NS for some reason.  I already created the custom data class, so not sure why that is occurring.

    This is a fun case of with each issue solved a new one appears. :)



  • 13.  RE: Custom Inventory Samples for NS6

    Posted Dec 16, 2010 04:46 PM

    Ok here is the modified script that will send data to the NS. The script I provided previously was for testing to make sure it was the All Users folder causing the issue.

     

    ''' Altiris Stuff
    'Create instance of Altiris NSE component
    dim nse
    set nse = WScript.CreateObject ("Altiris.AeXNSEvent")
    ' Set the header data of the NSE.  Please don't modify this GUID
    nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    nse.Priority = 1
    dim objDCInstance
    set objDCInstance = nse.AddDataClass ("cust_user_profile")
    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)
    ''' End of Altiris Stuff

    ' Create a filesystem object for the 'documents and settings' folder, then
    ' loop thru each subdirectory and get it's name, etc.
    set fs = CreateObject("Scripting.FileSystemObject")
    set folder = fs.GetFolder("C:\Documents and Settings")
    For each item in folder.SubFolders
        Set subF = CreateObject("Scripting.FileSystemObject")
        set subFolder = subF.GetFolder(item.path)
     If InStr(subFolder.Name,"All Users") = 0 then
      Wscript.echo "folder.Name=" & subFolder.Name
      Wscript.echo "folder.Path=" & subFolder.Path
      Wscript.echo "folder.Size=" & subFolder.Size
       
      'Add a new row
      dim objDataRow
      set objDataRow = objDataClass.AddRow
      'Set columns
      objDataRow.SetField 0,  subFolder.Name
      objDataRow.SetField 1,  subFolder.Path
      objDataRow.SetField 2,  subFolder.Size
     End If
    Next      
    ''' Altiris Stuff
    ' Send the NSE data to the NS server
    nse.SendQueued
    ''' End of Altiris Stuff
    ''' End of vbscript main logic



  • 14.  RE: Custom Inventory Samples for NS6

    Posted Dec 17, 2010 11:24 AM

    At this point the XP one in the original post is working correctly.  It's running it on Windows 7 that is causing us fits. It appears that security restrictions prevent reading c:\Users.  If we went to a specific folder such as c:\Users\MyProfile\My Documents it will work.

    This has me thinking about using a custom user token in the VB Script, if possible.  Time to read up on that.