Test only DSC resources

This topic contains 2 replies, has 2 voices, and was last updated by  Julien Nury 2 months, 1 week ago.

  • Author
    Posts
  • #96143

    Julien Nury
    Participant

    Hi all,

    For some use cases, our DSC deployments depend on non-DSC resources (an open TCP port on a remote machine, a version of a remote service etc.).

    I wonder if writing a DSC custom resource that just has payload in the Get and Test functions (and an empty Set function) is a good idea or an heresy ? The DSC configuration would fail fast and not deploy anything if prerequisites are not compliants.

    Are you aware of such resources in the wild ?

  • #96176

    Michael Greene
    Participant

    Here's a good working example. The Test just returns an immediate true/false regarding the state of the remote thing (in this case AD) and Set manages how long to wait for it to be in the required state and logging. That way you can run test-dscconfiguration without waiting on a timer.

    https://github.com/PowerShell/xActiveDirectory/blob/dev/DSCResources/MSFT_xWaitForADDomain/MSFT_xWaitForADDomain.psm1#L78

  • #96177

    Julien Nury
    Participant

    Nice example, thank you !

You must be logged in to reply to this topic.