Set-TargetResource

The Set-TargetResource function actually brings the state of the system to the desired state. This is the place where idempotency comes into play; the PowerShell code here is responsible for detecting the current state and only changing it if it does not match what is expected.

This function is required to implement all Key, Required, and Write parameters defined in the DSC resource definition file. Key and Required properties are required to be defined as mandatory parameters.

A Set-TargetResource function does not return any value to the calling code. This function either succeeds or fails; it does not indicate any state in between. Failure is indicated by throwing an exception with message text indicating the failure. Success is indicated by the function completing without error.

Optionally, a Set-TargetResource function can support the WhatIf PowerShell behavior and provide a summary of what would be changed on a target node without actually changing the target node state. The function can support this by implementing PowerShell's SupportsShouldProcess feature.

If the target node must be restarted after Set-TargetResource has successfully implemented the changes it was instructed to do, it can indicate this to the DSC engine by setting the global variable $global:DSCMachineStatus to 1 before exiting.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset