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"
}
}
}