The following walkthrough demonstrates how to create a dynamic agent plugin to read a registry entry from a Windows machine and store the information in a custom attribute.



  • Enter the following code in the Execute() method.

    /// <summary>
    /// Provides the code executed by this plugin.
    /// </summary>
    public override void Execute()
    {
           if (!PowerShell.IsConnected)
           {

                // Handle PowerShell not being connected.        
       }
       String customValue = PowerShell.Registry.GetStringValue(@"SOFTWARE\CENTREL Solutions\XIA Configuration Service", "InstallDirectory");

Item.CustomAttributes.Items.Add(new Guid("343eb509-c977-47b9-ba41-28d733405839"), String.Empty, customValue);
    }


  • The Registry property of the PowerShell support classes allows for direct access to the registry of the remote machine. In the example the "InstallDirectory" registry value of type REG_SZ is read. 

  • As the plugin is running after agent scan, the Item property provides access to the data generated by the agent, which can be modified. The custom attribute is added to the collection. The unique identifier of the custom attribute is the value that was noted at the start of this walkthrough.

    Item.CustomAttributes.Items.Add(new Guid("343eb509-c977-47b9-ba41-28d733405839"), String.Empty, customValue);

  • Click the validate compilation button to ensure the code compiles correctly, and then click the save button.

  • Close the dynamic code editor and click the OK button.

  • Go to the scan profile that you are editing and go to the default agent settings and then the Windows machine agent settings.

  • On the plugins tab right click the newly created dynamic agent plugin and select enable.