Client Management Suite

 View Only
  • 1.  Need vb script

    Posted Feb 14, 2018 02:37 PM

    Recenlty realized on older version of Altiris, I had mapped drives in inventory in table Inv_HW_Logical_Disk.  When running an SQL against ne db, I found that info missing.  Researching, came across and article that stated inventory does not capture printers and mapped drives: https://support.symantec.com/en_US/article.TECH145268.html.  Creating a neew policy as outlined did not work I need a vb script to  get HKEY Current User\Network subkeys (name) and its corresponding strvaluename "remotePath" and its value.

    I was able to get this on some pcs woth powershell, but on most it is not returning all mapped drives.  Better success on WIn 7 and less so on Win 8.1 and 10. Possibly  restriction on powershell running.

    After trying to work with many vb scripts and piece it together, I am still nowhere.

     So, I need a script to replace what Altiris Inventory USED to do. I already have the custom table with some info from the powershell script, but perhaps vb would be better.

    For each Drive letter, I need the RemotePath  value.  For example L: RemotePath value is \\oi-oitnst-m3-e.njes.state.nj.us\softwarelibrary

    THE GUID of the table is e30cf469-1720-4452-b3bc-7248d42a861a and the columns are Name ( the mapped drive letter (subkey) and ProviderName ( the path value).

    I do not script so this is quite difficult.  Any help would be appreciated



  • 2.  RE: Need vb script

    Posted Feb 16, 2018 10:15 AM

    I still think it would it be easier to clone the inventory that contains the user specific data and have it run under the user context. We have it here without issue.

    If you want to go the custom inventory route, you can modify the below VBS, run as the user, to include code for custom inventory. Symantec has written quite a few good articles on that.

    HTH

    https://support.symantec.com/en_US/article.HOWTO124413.html

    https://support.symantec.com/en_US/article.HOWTO10487.html

    Set objNetwork = WScript.CreateObject("WScript.Network")
    Set colDrives = objNetwork.EnumNetworkDrives
    For i = 0 to colDrives.Count-1 Step 2
     Wscript.Echo colDrives.Item(i) & vbTab & colDrives.Item (i + 1)
    Next 
     
     
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") 
    Set colInstalledPrinters = objWMIService.ExecQuery ("SELECT * FROM Win32_Printer") 
    For Each objPrinter in colInstalledPrinters 
    	wscript.echo "Name: " & objPrinter.Name & vbtab & "Location: " & objPrinter.Location 
    Next 

     



  • 3.  RE: Need vb script

    Posted Feb 20, 2018 07:06 AM

    Thank you- I did try the inventory .  Created a second inventory with the boxes checked per the article, yet it did not collect (or post) the info. Would have preferred this method than yet another custom inventory and tables.  From the article, I was a bit unclear as to if the results are collected, will it append the inventory or  delete/overwrite the existing inventory?



  • 4.  RE: Need vb script

    Posted Feb 20, 2018 08:52 AM

    The scripts run great and display the data.  I am trying to get this to write to the custom table.  I do not know the rest of the script when it comes to what the syntax should be to write.

    For example from a working script:


    'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server
    dim objDCInstance
    set objDCInstance = nse.AddDataClass ("{1bdec3a9-62b3-45c7-a65f-99b411c451b3}")

    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)

     
    'Add a new row
    dim objDataRow
    set objDataRow = objDataClass.AddRow
    'Set columns
    objDataRow.SetField 0, dwValue

    nse.SendQueued



  • 5.  RE: Need vb script

    Posted Feb 23, 2018 12:07 PM

    I finally have the vb script collecting just the info I need.  Used a Microsoft script and worked through it removing case and other elements.  When it runs it  display s exactly what I need, i.e. (Name) L: (ProviderName) \\path to mapped drive.  It enumerates throughHKCU Network and echoes all of them so I am sure it is working.  When I try to send that to the db, it does not update the table, yet the task instance details output  shows  Status Complete and all the mapped drive details under Output Properties

    It must be that what the data type collected is not what I am instructing it to write at the  near end of the sript:

    ' Set the header data of the NSE
    ' Please don't modify this GUID
     
    nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    nse.Priority = 1

    'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server
    dim objDCInstance
    set objDCInstance = nse.AddDataClass ("{e30cf469-1720-4452-b3bc-7248d42a861a}")

    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)

     
    'Add a new row
    dim objDataRow
    set objDataRow = objDataClass.AddRow
    'Set columns
    objDataRow.SetField 0, strSubkey
    objDataRow.SetField 1,  strValue
     
    nse.SendQueued

    Attachment(s)



  • 6.  RE: Need vb script

    Posted Feb 26, 2018 10:50 AM

    PowerShell may be a better option. It allows you to test executing the data collection, quite easily, outside of the code. An example (NOT tested) might be...

    #region SendDataToSMP
    function SendDataToSMP {
    	[CmdletBinding(SupportsShouldProcess=$True,DefaultParameterSetName="None")]
    	PARAM(
            [Parameter(Position = 0, Mandatory = $False, ValueFromPipeline = $True)] 
    		$InputObject
    		,
            [Parameter(Position = 1, Mandatory = $True, ValueFromPipeline = $True)] 
    		[string]
    		$DataClass
    		,
            [Parameter(Position = 2, Mandatory = $False, ValueFromPipeline = $True)] 
    		[switch]
    		$Upload
    		,
            [Parameter(Position = 3, Mandatory = $False, ValueFromPipeline = $True)]
    		[switch]
    		$Clear
    		,
            [Parameter(Position = 4, Mandatory = $False, ValueFromPipeline = $True)] 
    		[switch]
    		$ViewXML
            ,
            [switch]
            $NoNulls
    	)
    
    	# Create instance of Altiris NSE component
    	try {
    		$AeXNSEvent = New-Object -ComObject Altiris.AeXNSEvent
    
    		# Set the header data of the NSE
    		# This specifies the iteam as a Basic Inventory Capture Item (This should not be modified)
    		$AeXNSEvent.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    		$AeXNSEvent.Priority = 1
    
    		# This is the Guid assigned to the Data Class within SMP.
    		# CAUTION: In earlier versions of SMP, this changes every time the Data Class definition is modified!
    		# The Guid must be enclosed in braces. Otherwise, it considers it the name and does not work.
    		if ($DataClass -is [Guid]) {$DataClass = ([Guid]$DataClass).ToString('B')}
    		                   
    		# Create section based on Data Class guid
    		$DataClassInstance = $AeXNSEvent.AddDataClass($DataClass)
    		$DataBlockInstance = $AeXNSEvent.AddDataBlock($DataClassInstance)
    
    		if ($InputObject -and (!$Clear)) {
    			foreach ($Object in $InputObject) {
    				$RowInstance = $DataBlockInstance.AddRow()
    				$Object | foreach {
    					$Iteration = 0
    					foreach ($Property in $_.PSObject.Properties) {
    	                    $Value = $Property.Value
    	                    if (($NoNulls) -and $Value -eq $null) {$Value = ''}
    						if ($Value -ne $null) {$RowInstance.SetField($Iteration, "$($Value)")}
    						$Iteration++
    					}
    				}	
    			}
    		}
    
    		# Show
    		if ($ViewXML) {$AeXNSEvent.xml}
    		
    		# Queue NSE for upload
    		if ($Upload) {$AeXNSEvent.SendQueued()}
    	} catch {
    	}
    }
    #endregion
    
    $Data = Get-ItemProperty -Path "Registry::HKEY_CURRENT_USER\Network\*" | Select @{Name="DriveLetter";Expression={"$($_.PSChildName):"}},RemotePath
    
    SendDataToSMP -InputObject $Data -DataClass "E30CF469-1720-4452-B3BC-7248D42A861A" -ViewXML

    A couple of things to know about the SendDataToSMP function. The Select statement on the InputObject provides the order for the rows of the DataClass in the SMP database.

    The above code should allow for testing to see what the output looks like. Change -ViewXML to -Upload to send data to the database.

    Cheers



  • 7.  RE: Need vb script
    Best Answer

    Posted Feb 28, 2018 06:53 AM

    Thank you.   I tried powershell which works on some pcs.  However, it  is restricted on most pcs in our environment, so that option would not work.

     Since posting, I have my solution.  Thanks all.