Kaseya Community

Grab Registry Key and add value to custom field.

This question is answered

Hi there,

I am new to Kaseya and was wondering if someone can help clear up what I am doing wrong?

Essentially, I wan't to grab a license key from the registry and update a custom audit field.

When I run it, it says success but does not update the custom field.


<ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
<Procedure name="Get ShadowProtect License" treePres="3" id="792287944" folderId="252621005546591" treeFullPath="myProcedures - admin">
<Body description="">
<If description="Check if ShadowProtect appears to be installed">
<Condition name="TestRegistryKey">
<Parameter xsi:type="StringParameter" name="Path" value="HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\ShadowProtectSvc\Parameters"/>
<Parameter xsi:type="EnumParameter" name="Condition" value="Exists"/>
</Condition>
</If>
<If description="">
<Condition name="CheckRegistryValue">
<Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\ShadowProtectSvc\Parameters\SerialNumber"/>
<Parameter xsi:type="EnumParameter" name="Condition" value="Exists"/>
<Parameter xsi:type="StringParameter" name="Value" value=""/>
</Condition>
<Then>
<Statement name="GetVariable" continueOnFail="false" osType="Windows">
<Parameter xsi:type="EnumParameter" name="VariableType" value="RegistryValue"/>
<Parameter xsi:type="StringParameter" name="SourceContent" value="HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\ShadowProtectSvc\Parameters\SerialNumber"/>
<Parameter xsi:type="StringParameter" name="VariableName" value="ShadowProtectLic"/>
</Statement>
</Then>
</If>
<Statement name="UpdateSystemInfo" continueOnFail="false">
<Parameter xsi:type="StringParameter" name="ColumnName" value="ShadowProtect_Key"/>
<Parameter xsi:type="StringParameter" name="Value" value="#ShadowProtectLic#"/>
</Statement>
</Body>
</Procedure>
</ScriptExport>

Verified Answer
  • Hi Daryl, I suspect this is a variable 'scoping' issue. Try indenting your 'UpdateSystemInfo' step so that it becomes part of the If test. Alternatively try defining the variable as global:ShadowProtect_Key and then referencing it as #global:ShadowProtect_Key#

    See here for more on variables and their scope: help.kaseya.com/.../9040000

All Replies
  • Hi Daryl, I suspect this is a variable 'scoping' issue. Try indenting your 'UpdateSystemInfo' step so that it becomes part of the If test. Alternatively try defining the variable as global:ShadowProtect_Key and then referencing it as #global:ShadowProtect_Key#

    See here for more on variables and their scope: help.kaseya.com/.../9040000