Dependson Question

Hi
I’m have been given many different servers using different images(some older some more recent)
as beginning I’m trying to use dsc to configure three servers(later about 30 servers) to make sure that some have hyper-v and not iis and some I want both
and all have snmp(for monitoring) installed before I even check for the two other windows features.
will something like this work for me(it seem to work I’m just not sure my dependson is right):

$ConfigurationData = @{
AllNodes = @(
@{NodeName = ‘Demoserver1’;Role=‘Web’},
@{NodeName = ‘DemoServer2’;Role=‘Hyper-V’}
@{NodeName = ‘DemoServer3’;Role=‘Hyper-V’,‘web’}

)
}

configuration RoleConfiguration
{
param ($Roles)

switch ($Roles)
{
    'Hyper-V' {
                    WindowsFeature FileSharing
                    {
                        Name = 'Hyper-V'
                    } 
                }
    'Web'       {
                    WindowsFeature Web
                    {
                        Name = 'web-Server'
		    Ensure = 'absent'
                    } 
                }        
}

}

configuration ExtraConfig
{
node $allnodes.NodeName
{
WindowsFeature snmp
{
Name = ‘SNMP-Service’
}

    RoleConfiguration MyServerRoles
    {
    	Roles = $Node.Role
	}
}

}

configuration ExtraConfig
{
node $allnodes.NodeName
{
WindowsFeature snmp
{
Name = ‘SNMP-Service’
}

    RoleConfiguration MyRoles
    {
    	Roles = $Node.Role
    	DependsOn = '[WindowsFeature]snmp'
	}
}

}

Thanks

The code’s a bit hard to follow since you didn’t format it, but yeah - broadly, I think you’ve got it, if I’m understanding your intent. “MyRoles” won’t run until “SNMP” returns success.

Thanks Don
i actually used one of your posts to “build” a concept for this
i have 2 more small questions:
1.if i list the feature like this:
‘Hyper-V’ {
WindowsFeature Hyper-v
{
Name = ‘Hyper-V’

but i dont include Ensure will it also install it if needed?

  1. on dependson, if i put snmp as “prereq” will it install it also or will it just check to see if its installed and if not will not run the upper portion of the code ?

Thanks

  1. Why not try and see?

  2. If it isn’t installed it will attempt to install it. If that doesn’t throw an error it will - that’s the whole point of DSC, right? And then proceed.