Strange error when executing configuration file

Tagged: ,

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Wei-Yen Tan Wei-Yen Tan 10 months ago.

  • Author
    Posts
  • #34895
    Profile photo of Wei-Yen Tan
    Wei-Yen Tan
    Participant

    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
    + ~~~~~~~~~~~~~
    + 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"
                }
    
              }
     
     }
     
  • #34941
    Profile photo of Wei-Yen Tan
    Wei-Yen Tan
    Participant

    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.

You must be logged in to reply to this topic.