Client Management Suite

Expand all | Collapse all

Search for folders with custom inventory

  • 1.  Search for folders with custom inventory

    Posted 09-15-2020 04:17 PM
    Hello everyone,
    I have a audit controll where I have to provide an evidence that some specific folders are not on the servers, so for example C:\foldername, C:\foldername2.
    I'm planning to use a custom inventory to collect this data and then from there I can run a report as evidence. So the script output should look like:

    C:\foldername - Folder not found!
    C:\foldername2 - Folder not found!

    Does anyone already something like this that could share? Would it be better to write the script in Vbscript or Powershell?

    Thanks in advance.

  • 2.  RE: Search for folders with custom inventory

    Broadcom Employee
    Posted 10-13-2020 12:12 PM
    Hi Alex - here's a VB script that may help:

    ' VB Script to check for folders
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    Set wshShell = WScript.CreateObject( "WScript.Shell" )
    ComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
    set nse = WScript.CreateObject ("Altiris.AeXNSEvent")
    nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    nse.Priority = 1

    ' This is the GUID from the custom data class:
    set objDCInstance = nse.AddDataClass ("{GUID from custom data class}")

    set objDataClass = nse.AddDataBlock (objDCInstance)
    Set FSO = CreateObject("Scripting.FileSystemObject")
    set objDataRow = objDataClass.AddRow

    TargetFolder1 = "C:\Program Files\Folder1"
    TargetFolder2 = "C:\Program Files\Folder2"

    objDataRow.SetField 0, ComputerName

    if (FSO.FolderExists(TargetFolder1)) then
    objDataRow.SetField 1, "TargetFolder1 Found"
    objDataRow.SetField 1, "TargetFolder1 Not Found"
    end if

    if (FSO.FolderExists(TargetFolder2)) then
    objDataRow.SetField 2, "TargetFolder2 Found"
    objDataRow.SetField 2, "TargetFolder2 Not Found"
    end if
    objDataRow.SetField 3, "As of:" + " " + Cstr(now) 'Date of inventory

    'MsgBox nse.Xml 'used for testing on local machine only