Quantcast
Channel: Symantec Connect - Endpoint Management
Viewing all articles
Browse latest Browse all 7217

How to Create a CMD Custom Inventory File

$
0
0

Symantec only provides custom VBS examples with Inventory Solution 7.x, and the 6.x examples are a mixture of XML & VBS. 

As there are no examples on how to create a CMD custom inventory file, I thought I would take the opportunity whilst on site to provide the community with pointers on how to do this. 

The reason that I can only give pointers is because I am not allowed to share the fully functional CMD file. 

Below are a number of snippets that relate directly to the NSI file that will be created from the scan, that relate to this line:- 

XEcho "<z:row c0='%patch_report_date%' c1='%patch_current_datetime%' c2='%patch_num_analysis%' c3='%patch_num_nodef%' c4='%patch_num_total%' c5='%patch_exclude%' c6='%patch_bulletin_list%' />">>"%nsifile%""
:: Setup variables
set patch_report_date=

set patch_current_datetime=
set patch_current_datetime=%patch_nsivalue%
:: Set and check if this machine is excluded from patch management

    :: Transfer exclude bit from old to new location, if present
    set patch_exclude=
    for /f "tokens=1,*" %%i in ('REG.exe -ListVal "%patch_exclude_key_old%"') do if "%%j" == "1" set patch_exclude=1
    if defined patch_exclude reg.exe -Deletevalue "%patch_exclude_key_old%"
    if defined patch_exclude %SystemsManagement_KeyControlEXE% /quiet /disable:patch_management

REM    if defined opt_exclude_on  reg.exe -Set "%patch_exclude_key_old%"=1
REM    if defined opt_exclude_off reg.exe -Deletevalue "%patch_exclude_key_old%"
    if defined opt_exclude_on  %SystemsManagement_KeyControlEXE% /quiet /disable:patch_management
    if defined opt_exclude_off %SystemsManagement_KeyControlEXE% /quiet /enable:patch_management
    set patch_exclude=
    for /f "tokens=1,*" %%i in ('REG.exe -ListVal "%patch_exclude_key%"') do if "%%j" == "1" set patch_exclude=1
:: Step 1: Check for patches

    set /a patch_num_total=0
    set /a patch_num_analysis=0
    set /a patch_num_nodef=0
    set patch_bulletin_list=
    set patch_bulletin_list_custom=
:: Send Patch Status to Altiris Inventory
:: Report a "green" status to server by sending the current package definition date
    set patch_report_date=%definition_date%

:IsNotInstalled

    call :sendnsi_PatchStatus
::sendnsi_PatchStatus
:: - create an nsi file and send to NS

    call :sendnsi_prepare

::    Delete old bak/nsi files which may block AeXInvCollector
    del /f /q "%TEMP%\PatchStatus.bak"
    del /f /q "%TEMP%\PatchStatus.nsi"
    sleep 5

::    PatchStatus table
    set nsifile=%inventory_dir%\PatchStatus.nsi

    XEcho "<InventoryClasses>">"%nsifile%"
    XEcho "<InventoryClass name='PatchStatus' manufacturer='Manufacturer1' description='' version='1.0' platform='Win32' mifClass='Manufacturer1|PATCH_STATUS|1.0'>">>"%nsifile%"
    XEcho "<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'>">>"%nsifile%"
    XEcho "<s:Schema id='RowsetSchema'>">>"%nsifile%"
    XEcho "<s:ElementType name='row' content='eltOnly' rs:updatable='true'>">>"%nsifile%"
    XEcho "<s:AttributeType name='c0' rs:name='DefinitionDate' rs:number='1' rs:basecolumn='DefinitionDate' rs:keycolumn='true' mifAttrId='1'>">>"%nsifile%"
    XEcho "<s:datatype dt:type='string' dt:maxLength='255'/>">>"%nsifile%"
    XEcho "</s:AttributeType>">>"%nsifile%"
    XEcho "<s:AttributeType name='c1' rs:name='LastCheckDate' rs:number='2' rs:basecolumn='LastCheckDate' rs:keycolumn='true' mifAttrId='2'>">>"%nsifile%"
    XEcho "<s:datatype dt:type='string' dt:maxLength='255'/>">>"%nsifile%"
    XEcho "</s:AttributeType>">>"%nsifile%"
    XEcho "<s:AttributeType name='c2' rs:name='MissingByAnalysis' rs:number='3' rs:basecolumn='MissingByAnalysis' rs:nullable='true' mifAttrId='3'>">>"%nsifile%"
    XEcho "<s:datatype dt:type='int' dt:maxLength='4'/>">>"%nsifile%"
    XEcho "</s:AttributeType>">>"%nsifile%"
    XEcho "<s:AttributeType name='c3' rs:name='MissingDefinition' rs:number='4' rs:basecolumn='MissingDefinition' rs:nullable='true' mifAttrId='4'>">>"%nsifile%"
    XEcho "<s:datatype dt:type='int' dt:maxLength='4'/>">>"%nsifile%"
    XEcho "</s:AttributeType>">>"%nsifile%"
    XEcho "<s:AttributeType name='c4' rs:name='ReadyToInstall' rs:number='5' rs:basecolumn='ReadyToInstall' rs:nullable='true' mifAttrId='5'>">>"%nsifile%"
    XEcho "<s:datatype dt:type='int' dt:maxLength='4'/>">>"%nsifile%"
    XEcho "</s:AttributeType>">>"%nsifile%"
    XEcho "<s:AttributeType name='c5' rs:name='PatchMgmtExclude' rs:number='6' rs:basecolumn='PatchMgmtExclude' rs:nullable='true' mifAttrId='6'>">>"%nsifile%"
    XEcho "<s:datatype dt:type='string' dt:maxLength='255'/>">>"%nsifile%"
    XEcho "</s:AttributeType>">>"%nsifile%"
    XEcho "<s:AttributeType name='c6' rs:name='MissingBulletinList' rs:number='7' rs:basecolumn='MissingBulletinList' rs:nullable='true' mifAttrId='7'>">>"%nsifile%"
    XEcho "<s:datatype dt:type='string' dt:maxLength='1023'/>">>"%nsifile%"
    XEcho "</s:AttributeType>">>"%nsifile%"
    XEcho "</s:ElementType>">>"%nsifile%"
    XEcho "</s:Schema>">>"%nsifile%"
    XEcho "<rs:data>">>"%nsifile%"
    XEcho "<z:row c0='%patch_report_date%' c1='%patch_current_datetime%' c2='%patch_num_analysis%' c3='%patch_num_nodef%' c4='%patch_num_total%' c5='%patch_exclude%' c6='%patch_bulletin_list%' />">>"%nsifile%"
    XEcho "</rs:data>">>"%nsifile%"
    XEcho "</xml>">>"%nsifile%"
    XEcho "</InventoryClass>">>"%nsifile%"
    XEcho "</InventoryClasses>">>"%nsifile%"
:: - and send it to server
::   (We don't really need the wrapper here, we just observed that this program sometimes
::   crashes with a message box without content! The reason is unknown, but wrapper seem to help here...)

	wrapper -w AeXNSInvCollector.exe /hidden /nsctransport /v default /useguid
	wrapper -w AeXNSInvCollector.exe /hidden /nsctransport /v default /useguid /s "%TEMP%"
	goto :EOF


:sendnsi_prepare
	if not exist "%ProgramFiles%\Altiris" mkdir "%ProgramFiles%\Altiris"
	if not exist "%ProgramFiles%\Altiris\eXpress" mkdir "%ProgramFiles%\Altiris\eXpress"
	if not exist "%ProgramFiles%\Altiris\eXpress\Inventory" mkdir "%ProgramFiles%\Altiris\eXpress\Inventory"
	set inventory_dir=%ProgramFiles%\Altiris\eXpress\Inventory
	for /f "tokens=1 delims=[]" %%i in ('ddate /e') do set patch_current_datetime=%%i
	goto :EOF


:get_nsivalue
:: Usage: call :get_nsivalue filename-without-extension fieldname
:: returns value in "patch_nsivalue"
	call :sendnsi_prepare
	set x=%inventory_dir%\%~n1.nsi
	if not exist "%x%" set x=%inventory_dir%\%~n1.bak
	if not exist "%x%" set x=
	set y=
	set z=
	if defined x for /f "tokens=1,* delims==" %%i in ('getxml -n "rs:name=%2" -i "%x%""InventoryClasses\InventoryClass\xml\s:Schema\s:ElementType\s:AttributeType""name"') do set y=%%j
	if defined y for /f "tokens=1,* delims==" %%i in ('getxml -i "%x%""InventoryClasses\InventoryClass\xml\rs:data\z:row""%y%"') do set z=%%j
	set patch_nsivalue=%z%
	goto :EOF

This should hopefully give you enough insight as to how to create a fully functional scan file. 


Viewing all articles
Browse latest Browse all 7217

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>