Custom inventory example

Custom inventory example

' Customer function for collecting custom inventory. Dim sVersion sBuild="1"    Private Function GetDefaultUSer() Dim sxmlFile, oNodeList, sUser 'Begin   On Error Resume Next   bStatus=True   If bStatus Then bStatus=Job_WriteLog("GetDefaultUSer","Get default user",bStatus,True)   If bStatus Then      sxmlFile=gsWorkstationpath & "Agent\" & gsWorkstationname & ".lgi"     Set oxmlDoc = CreateObject("Msxml2.DOMDocument")     If isObject(oxmlDoc) Then       oxmlDoc.Load (sxmlFile)       Set oNodeList = oxmlDoc.selectNodes("//Inventory/Section [@Value= " & Chr(34) & "Default User" & Chr(34) & "]")       For each oNode in oNodelist         sUser=Trim(Mid(oNode.Text,1,Instr(oNode.Text," ")-1))       Next     End if   End If     If bStatus Then bStatus=Job_WriteLog("GetDefaultUSer","Found default user '" & sUser & "'",bStatus,True)   GetDefaultUSer=sUser End Function Function GetDepartment(sUser) Dim bStatus, objUser, sDept 'Begin   On Error Resume Next   bStatus=True   If bStatus Then bStatus=Job_WriteLog("GetDepartment","Get default user department",bStatus,True)   Set objUser = GetObject("LDAP://cn=" & sUser & ",cn=USERS,dc=Test,dc=local")   If isObject(objUser) Then      objUser.GetInfo     sDept=objUser.Get("department")   Else     sDept=""   End If   If bStatus Then bStatus=Job_WriteLog("GetDepartment","Default user department '" & sDept & "'",bStatus,True)   GetDepartment=sDept End Function Private Function CustomInventory() Dim bStatus   'Begin   On Error Resume Next 'Avoid runtime errors   bStatus=True 'initialize as True   If bStatus Then bStatus=Job_WriteLog("CustomInventory","Custom Inventory Script build " & sBuild,bStatus,True)      If bStatus Then sUser=GetDefaultUSer()   If bStatus and (sUser<>"") Then      If bStatus Then sDept=GetDepartment(sUser)     If bStatus and (sDept<>"") Then       If bStatus Then bStatus=Ini_WriteEntry(gsWorkstationPath & "Agent\" & gsWorkstationName & ".csi","Customer Inventory","Department",sDept)     End If     End If          If bStatus Then bStatus=Job_WriteLog("CustomInventory","Custom Inventory Script end.",bStatus,True)   CustomInventory=bStatus End Function