Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Severity Level: Information
Default state: Always enabled
Description
This rule detects if Desired State Configuration (DSC) examples for a given resource are present.
To fix a violation of this rule, you must ensure that the Examples directory exists for:
- Non-class based resources, it should be at the same folder level as the
DSCResourcesfolder. - Class based resources, it should be at the same folder level as the resource's
.psm1file.
The Examples folder must contain a sample configuration for the resource. The filename should
include the resource's name.
Example
Non-class based resource
Let's assume we have non-class based resource with the following file structure:
- xAzure
- DSCResources
- MSFT_xAzureSubscription
- MSFT_xAzureSubscription.psm1
- MSFT_xAzureSubscription.schema.mof
- MSFT_xAzureSubscription
- DSCResources
In this case, to fix this warning, add examples in the following way:
- xAzure
- DSCResources
- MSFT_xAzureSubscription
- MSFT_xAzureSubscription.psm1
- MSFT_xAzureSubscription.schema.mof
- MSFT_xAzureSubscription
- Examples
- MSFT_xAzureSubscription_AddSubscriptionExample.ps1
- MSFT_xAzureSubscription_RemoveSubscriptionExample.ps1
- DSCResources
Class based resource
Let's assume we have class based resource with the following file structure:
- MyDscResource
- MyDscResource.psm1
- MyDscResource.psd1
In this case, to fix this warning, add examples in the following way:
- MyDscResource
- MyDscResource.psm1
- MyDscResource.psd1
- Examples
- MyDscResource_Example1.ps1
- MyDscResource_Example2.ps1
Configure rule
This rule is always enabled and isn't configurable. Use one of the following methods to avoid using this rule:
- Create a custom rule configuration file to include only the rules you want or exclude the rules you don't want.
- Add the appropriate rule suppression attributes to your code to suppress the rule for specific code blocks. For more information, see the Suppressing rules section of Using PSScriptAnalyzer.