Book Image

Learning PowerShell DSC

By : James Pogran
Book Image

Learning PowerShell DSC

By: James Pogran

Overview of this book

Table of Contents (14 chapters)
Learning PowerShell DSC
About the Author
About the Reviewers

Testing custom DSC Resources

There are a few methods available to you to test the custom DSC Resources you have created, whether they are PowerShell v4- or v5-based.

Using xDscResourceDesigner

We covered using xDscResourceDesigner in the previous section on creating module-based DSC Resources, but automating DSC Resource creation is not the only trick up this module's sleeve. The two Cmdlets, Test-xDscResource and Test-xDscSchema, provided by this module aid in testing your custom DSC Resources.

Test-xDscResource and Test-xDscSchema will check your custom DSC Resource to make sure that the data types are the same between your DSC MOF schema file and your DSC PowerShell script Get, Set, and Test-TargetResource functions, that the mandatory parameters are the same in all three functions, and that any parameters that are marked as Mandatory in the scripts are set to Required in the schema file.

You use Test-xDscSchema by providing it with a schema file to test:

 [PS]> Import-Module $env:ProgramFiles...