# Composite DSC resources with parameters

**URL:** <https://forums.powershell.org/t/composite-dsc-resources-with-parameters/2333>\
**Category:** PowerShell Help\
**Created:** [March 11, 2014, 5:57pm UTC](https://forums.powershell.org/t/composite-dsc-resources-with-parameters/2333 "2014-03-11T17:57:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bas-tichelaar](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/bas-tichelaar/32/868_2.png) [@bas-tichelaar](https://forums.powershell.org/u/bas-tichelaar)\
**Post date:** [March 11, 2014, 5:57pm UTC](https://forums.powershell.org/t/composite-dsc-resources-with-parameters/2333/1 "2014-03-11T17:57:28Z")

</div>

Hi all,

I’m having troubles supplying a composite resource with parameters. See [Powershell DSC: Composite Resources with parameters not working - Stack Overflow](http://stackoverflow.com/questions/22250744/powershell-dsc-composite-resources-with-parameters-not-working). Has anyone encountered the same problem?

Thanks!

---

<div class="post-metadata">

**Author:** ![robert-westerlund](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/robert-westerlund/32/877_2.png) [@robert-westerlund](https://forums.powershell.org/u/robert-westerlund)\
**Post date:** [March 11, 2014, 6:44pm UTC](https://forums.powershell.org/t/composite-dsc-resources-with-parameters/2333/2 "2014-03-11T18:44:15Z")

</div>

I have tried running the following, based on your example, and it works perfectly fine on the test computer (WIn8.1).

baseconfig.schema.psm1

```
Configuration BaseConfig
{    
    PARAM (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]$Teststring
    )
    
    File testfile
    {
        DestinationPath = "C:\testfile.txt";
        Contents = $teststring;
    }
}
```

testconfig.ps1:

```
import-module baseconfig -force

configuration testconfig
{
    import-dscresource -modulename baseconfig
    
    node localhost
    {
        BaseConfig common
        {
            TestString = "some value for the test string"
        }
    }
}

testconfig
```

---

<div class="post-metadata">

**Author:** ![bas-tichelaar](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/bas-tichelaar/32/868_2.png) [@bas-tichelaar](https://forums.powershell.org/u/bas-tichelaar)\
**Post date:** [March 11, 2014, 8:18pm UTC](https://forums.powershell.org/t/composite-dsc-resources-with-parameters/2333/3 "2014-03-11T20:18:20Z")

</div>

Hi Robert,

I did exactly that. But when running it, it complains about the parameters:

```auto

cmdlet BaseConfig at command pipeline position 1
Supply values for the following parameters:
Teststring: 
PSDesiredStateConfiguration\node : The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At E:\Dev\DSCResources\Modules\testconfig.ps1:7 char:5
+ node localhost
+ ~~~~
    + CategoryInfo : MetadataError: (:) [PSDesiredStateConfiguration\node], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ArgumentIsEmpty,PSDesiredStateConfiguration\node
Errors occurred while processing configuration 'testconfig'.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2088 char:5
+ throw $errorRecord
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (testconfig:String) [], InvalidOperationException
    + FullyQualifiedErrorId : FailToProcessConfiguration

```

BTW, I’m running Windows 2012R2 with all the latest updates. How important is the directory structure? I’m running the modules from a path included in the $psModulePath environment variable, in a subdir Modules\BaseConfig:

E:\Dev\DSCResources\Modules\testconfig.ps1  
E:\Dev\DSCResources\Modules\BaseConfig\baseconfig.psd1  
E:\Dev\DSCResources\Modules\BaseConfig\baseconfig.schema.psm1

Is this the correct way? Moving the tree to C:\Program Files\WindowsPowerShell\Modules\BaseConfig did not help.

---

<div class="post-metadata">

**Author:** ![robert-westerlund](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/robert-westerlund/32/877_2.png) [@robert-westerlund](https://forums.powershell.org/u/robert-westerlund)\
**Post date:** [March 11, 2014, 9:20pm UTC](https://forums.powershell.org/t/composite-dsc-resources-with-parameters/2333/4 "2014-03-11T21:20:27Z")

</div>

I’ve asked for a little more detailed information on your stackoverflow question, to see if I can successfully recreate the issue locally on my computer. Could you please edit your question there with the above mentioned information and the information I request in my comment there.

Also, it’d be nice if you’d provide a name on stackoverflow instead of being named ‘user1559544’. 🙂

---

<div class="post-metadata">

**Author:** ![bas-tichelaar](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/bas-tichelaar/32/868_2.png) [@bas-tichelaar](https://forums.powershell.org/u/bas-tichelaar)\
**Post date:** [March 11, 2014, 10:21pm UTC](https://forums.powershell.org/t/composite-dsc-resources-with-parameters/2333/5 "2014-03-11T22:21:26Z")

</div>

Hi Robert, thanks for your help. I changed my name and added more details 🙂

---

<div class="post-metadata">

**Author:** ![robert-westerlund](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/robert-westerlund/32/877_2.png) [@robert-westerlund](https://forums.powershell.org/u/robert-westerlund)\
**Post date:** [March 12, 2014, 9:38am UTC](https://forums.powershell.org/t/composite-dsc-resources-with-parameters/2333/6 "2014-03-12T09:38:04Z")

</div>

Wrote a blog post based on your StackOverflow question. The blog post holds [a guide on creating a composite DSC configuration](http://robertwesterlund.net/post/2014/03/12/creating-a-composite-dsc-configuration-with-parameters). Thought I should post a link to the blog post here, in case someone finds this thread through an internet search.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:52pm UTC](https://forums.powershell.org/t/composite-dsc-resources-with-parameters/2333/7 "2024-05-16T20:52:21Z")

</div>


