If statements and package deployment

I’ve been trying to add if statements to my DSC package deployments but it has been difficult finding info on it. What I’m trying is pretty basic, All I need to do is have the config check to see if package1 is installed and if it is then it doesn’t install package2 but if package 1 is absent then it installs package2.

Configuration DefaultApps 
{
    Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
    Node Localhost
    {
        Package package1
        { 
            Ensure    = "Present" 
            Path      = ".msi" 
            Name      = "package1" 
            ProductId = "" 
            Arguments = "AllUsers=1"
            DependsOn = ""
        }
        Package package2
        { 
            Ensure    = "Present" 
            Path      = ".msi" 
            Name      = "package2" 
            ProductId = "" 
            Arguments = "AllUsers=1"
            DependsOn = ""
        }
    }
}    

Pretty basic, but I’m very new to dsc so information resources would be very helpful.

What’s fighting you is that these configuration scripts must compile to a MOF, and MOFs don’t have logic in them. There’s no if/then branching.

The current Package resource doesn’t support an either/or scenario like you’re describing. You would probably need to create your own resource, so that in a single definition you could define both packages and implement your either/or logic within the resource’s script code.