> ## Documentation Index
> Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# powershell/PSDSCDscExamplesPresent

> DSC examples are present

`powershell/PSDSCDscExamplesPresent` is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.

| Property | Value             |
| -------- | ----------------- |
| Severity | Information       |
| Category | PSScriptAnalyzer  |
| Default  | Disabled in tally |
| Auto-fix | No                |

<Note>
  tally disables this rule by default because Desired State Configuration resources are out
  of scope for Dockerfile `RUN` analysis. Re-enable it with
  `include = ["powershell/PSDSCDscExamplesPresent"]` or by setting
  `rules.powershell.PSDSCDscExamplesPresent.severity = "warning"` in `.tally.toml`.
</Note>

## Description

Checks that DSC examples for given resource are present.

## How

To fix a violation of this rule, please make sure `Examples` directory is present:

* For non-class based resources it should exist at the same folder level as `DSCResources` folder.
* For class based resources it should be present at the same folder level as resource `.psm1` file.

The `Examples` folder should contain a sample configuration for given resource. The filename should
contain the resource's name.

## Examples

### Non-class based resource

Let's assume we have non-class based resource with a following file structure:

* xAzure
  * DSCResources
    * MSFT\_xAzureSubscription
      * MSFT\_xAzureSubscription.psm1
      * MSFT\_xAzureSubscription.schema.mof

In this case, to fix this warning, we should add examples in a following way:

* xAzure
  * DSCResources
    * MSFT\_xAzureSubscription
      * MSFT\_xAzureSubscription.psm1
      * MSFT\_xAzureSubscription.schema.mof
  * Examples
    * MSFT\_xAzureSubscription\_AddSubscriptionExample.ps1
    * MSFT\_xAzureSubscription\_RemoveSubscriptionExample.ps1

### Class based resource

Let's assume we have class based resource with a following file structure:

* MyDscResource
  * MyDscResource.psm1
  * MyDscResource.psd1

In this case, to fix this warning, we should add examples in a following way:

* MyDscResource
  * MyDscResource.psm1
  * MyDscResource.psd1
  * Examples
    * MyDscResource\_Example1.ps1
    * MyDscResource\_Example2.ps1

## Source

This rule documentation is adapted from Microsoft's PSScriptAnalyzer documentation for
[DSCDscExamplesPresent](https://github.com/MicrosoftDocs/PowerShell-Docs-Modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCDscExamplesPresent.md),
licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
