dsc_built_in_resource

This generic method defines if service should run or be stopped.

⚙️ Compatible targets: Windows

Parameters

NameDocumentation
tagInformative name.

This parameter is required.
resourceNameresourceName.

This parameter is required.
scriptBlockDesired state for the resource.

This parameter is required.

Outcome conditions

You need to replace ${tag} with its actual canonified value.

  • ✅ Ok: dsc_built_in_resource_${tag}_ok
    • ☑️ Already compliant: dsc_built_in_resource_${tag}_kept
    • 🟨 Repaired: dsc_built_in_resource_${tag}_repaired
  • ❌ Error: dsc_built_in_resource_${tag}_error

Example

method: dsc_built_in_resource
params:
  tag: VALUE
  resourceName: VALUE
  scriptBlock: VALUE

Documentation

Apply a given DSC resource to the node.

Parameters

  • tag parameter is purely informative and has no impact on the resource.
  • ResourceName must be the explicit name of the DSC resource you wish to apply
  • ScriptBlock must be a powershell script in plain text, returning an Hashtable containing the parameters to pass to the resource.

Note that this method can only apply built-in Windows resources. It will not be able to apply an external resource.

Example

If we want to apply a Registry resource. The resourceName used will be Registry And a potential ScriptBlock could be:

 $HKLM_SOFT="HKEY_LOCAL_MACHINE\SOFTWARE"
 $Ensure      = "Present"
 $Key         = $HKLM_SOFT + "\ExampleKey"

 $table = @{}
 $table.Add("Ensure", $Ensure)
 $table.Add("Key", $Key)
 $table.Add("ValueName", "RudderTest")
 $table.Add("ValueData", "TestData")
 $table

Note that all the ScriptBlock will be readable on the Rudder logs or in the policy files.