# Strange error when executing configuration file

**URL:** https://forums.powershell.org/t/strange-error-when-executing-configuration-file/5708
**Category:** DSC
**Created:** [February 4, 2016, 12:35pm UTC](https://forums.powershell.org/t/strange-error-when-executing-configuration-file/5708 "2016-02-04T12:35:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![wei-yen-tan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/wei-yen-tan/32/91_2.png) [@wei-yen-tan](https://forums.powershell.org/u/wei-yen-tan)
#### Post date: [February 4, 2016, 12:35pm UTC](https://forums.powershell.org/t/strange-error-when-executing-configuration-file/5708/1 "2016-02-04T12:35:46Z")

</div>

Hi,

I am trying to use the method of using a configuration parameter to pass to a configuration. This happenss when creating a mof.

However what i am finding is that i am getting this error:

`

PSDesiredStateConfiguration\Configuration : Cannot convert value “False” to type “System.Management.Automation.ScriptBlock”. Error: “Invalid cast from ‘System.Boolean’ to ‘System.Management.Automation.ScriptBlock’.”  
At C:\Scripts\DSC.ps1:1 char:1

- Configuration DSC\_Example
- 

```auto
  + CategoryInfo : InvalidArgument: (:) [Configuration], ParentContainsErrorRecordException
  + FullyQualifiedErrorId : InvalidCastIConvertible,Configuration

```

Errors occurred while processing configuration ‘DSC\_Example’.  
At C:\windows\system32\windowspowershell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2088 char:5

- 

```
throw $errorRecord

```

- 

```
~~~~~~~~~~~~~~~~~~

```

  - CategoryInfo : InvalidOperation: (DSC\_Example:String) , InvalidOperationException
  - FullyQualifiedErrorId : FailToProcessConfiguration

`

I am not quite sure what this is referring to…even though I have checked through help and online help.

Any guidance would be most grateful. I have my code below:

```
Configuration DSC_Example 
{
    param (
        [Parameter(Mandatory)]
     [pscredential]$safemodeAdministratorCred,
        [Parameter(Mandatory)]
    [pscredential]$domainCred,
	    [Parameter(Mandatory)]
    [pscredential]$DNSDelegationCred,
	
    [Parameter(Mandatory)]
    [pscredential]$LocalAdminCred
    )
    Import-DscResource -modulename xWebadministration, xActiveDirectory, xFailOverCluster, xcomputermanagement

  
   

        #Specifing configurations for each server. Specifying resource blocks.

        node $Allnodes.Where($_.role -eq "ADServer").nodename
        {
            WindowsFeature ADDSInstall
            {
                Ensure = "Present"
                Name = "AD-Domain-Services"
            }
            xADDomain FirstDS
            {
                DomainName = $Node.DomainName
                DomainAdministratorCredential = $domainCred
                SafemodeAdministratorPassword = $safemodeAdministratorCred
                DnsDelegationCredential = $DNSDelegationCred
                DependsOn = "[WindowsFeature]ADDSInstall"
            }
    

            WindowsFeature Graphical_Interface_Uninstall
            {
                Name ="Server-Gui-Mgmt-Infra"
                Ensure = "Absent"
            }
        }

        node $Allnodes.Where($_.role -eq "Webserver")
        {
            WindowsFeature IIS
            {
                    Name ="Web-Server"
                    Ensure ="Present"
            }

                 
            WindowsFeature IIS_Management_Service
            {
                    Name = "Web-Mgmt-Service"
                    Ensure = "Present"
                    DependsOn = '[WindowsFeature]IIS'
            }

           
            WindowsFeature IIS_Management_Service
            {
                    Name = "Web-Mgmt-Service"
                    Ensure = "Present"
                    DependsOn = '[WindowsFeature]IIS'
            }

            xWebsite DefaultSite 
            {
                Ensure = 'Present'
                Name = 'Default Web Site'
                State = 'Stopped'
                PhysicalPath = 'C:\inetpub\wwwroot'
                DependsOn = '[WindowsFeature]IIS'
            }

           xcomputer Add_Domain
           {
                Credential = $LocalAdminCred
                Dependson = "[WindowsFeature]ADDSInstall"
           } 

          WindowsFeature Graphical_Interface_Uninstall
            {
                Name ="Server-Gui-Mgmt-Infra"
                Ensure = "Absent"
            }

        }

         node $Allnodes.Where($_.nodename -eq "fs1")
          {
            xCluster FS
                
             {
                    DomainADministratorCredential = $domainCred
                    Name = "Failover"
                    StaticIPAddress = "192.168.1.111"
             }

           WindowsFeature Graphical_Interface_Uninstall
            {
                Name ="Server-Gui-Mgmt-Infra"
                Ensure = "Absent"
            }

          }
 
 }
```

---

<div class="post-metadata">

### Author: ![wei-yen-tan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/wei-yen-tan/32/91_2.png) [@wei-yen-tan](https://forums.powershell.org/u/wei-yen-tan)
#### Post date: [February 5, 2016, 4:32pm UTC](https://forums.powershell.org/t/strange-error-when-executing-configuration-file/5708/2 "2016-02-05T16:32:50Z")

</div>

I have revised the syntax and the layout of the original format and everything is looking good.

I segmented everything into individual roles and then everything started working from there…

This was for a lab and I just wanted to test that it was working with the design that I have above (getting things from a configurationfile.psd1).

Yay! Now onto the next one.

---

<div class="post-metadata">

### Author: ![mikemayops](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@mikemayops](https://forums.powershell.org/u/mikemayops)
#### Post date: [October 24, 2017, 3:25pm UTC](https://forums.powershell.org/t/strange-error-when-executing-configuration-file/5708/3 "2017-10-24T15:25:07Z")

</div>

I’m having the exact same issue right now. Could you please expand a little more on how you resolved this?

---

<div class="post-metadata">

### Author: ![alexander-johansson](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@alexander-johansson](https://forums.powershell.org/u/alexander-johansson)
#### Post date: [May 24, 2018, 8:03am UTC](https://forums.powershell.org/t/strange-error-when-executing-configuration-file/5708/4 "2018-05-24T08:03:55Z")

</div>

I know this is an old thread but I might aswell point out one obvious error in this configuration, which would generate this exact error. Also, if someone else is finding this thread they might be interested.

At line 22 he is doing the following:

```
node $Allnodes.Where($_.role -eq "ADServer").nodename
```

When the ‘Where’ query should be enclosed with {} and not (), like this:

```
node $Allnodes.Where{$_.role -eq "ADServer"}.nodename
```

/Alexander

---

<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, 9:16pm UTC](https://forums.powershell.org/t/strange-error-when-executing-configuration-file/5708/5 "2024-05-16T21:16:30Z")

</div>


