Author Posts

May 9, 2016 at 11:18 am

Cross-post from stack exchange

Is there a way to generate a MOF for all nodes? I.e. the node block is

Node * {...}

or the only entry in the config data is

{NodeName="*";...}

. If I run a configuration with these settings, PS will overwrite any existing servername.mof file to contain

@TargetName="*"

but it will not rename any of them nor will it generate a new MOF if the subdirectory is empty.

Is this possible or even a good idea?

May 9, 2016 at 12:12 pm

Theres no Partial Configurations for ConfigurationNames.

Partial configurations is only for GUID based registration.
ConfigurationNames is a RegistrationKey based registration.

At the moment ConfigurationNames accepts only one value, even though its defined as an array. The idea is that you use localhost as your node name, and then after the mof is created you rename it to the value you set in ConfiguratioNames

This way later on, if you want any of the nodes that use the same ConfigurationNames to get an update you create a new mof again and rename it to the value and all of them will get the new mof.

May 10, 2016 at 4:35 am

I have been able to create partial configurations using configuration names after finding this blog post: https://automationnext.wordpress.com/2016/04/19/powershell-desired-state-configuration-partial-configurations-without-configurationid/

The author created two ConfigurationRepositoryWeb blocks with one ConfigurationName in each but I was able to just use one with two configs listed in the array.

May 10, 2016 at 5:27 am

Thanks for the quick reply Arie and thank you for that blog post Alfano, it's always good to have a reference. I'm having the same results as you as the following configuration is currently working in my test environment.

[DscLocalConfigurationManager()]
Configuration PartialTest
{
    Param (
        [string[]]$ComputerName = 'localhost'
    )

    Node $ComputerName
    {
        Settings
        {
            ConfigurationMode = 'ApplyAndAutoCorrect'
            RefreshMode = 'Pull'
            RebootNodeIfNeeded = $true
            ActionAfterReboot = 'ContinueConfiguration'
        }
        
        ConfigurationRepositoryWeb PullServer
        {
            ServerURL = 'http://PullServer:8080/psdscpullserver.svc'
            RegistrationKey = '8945c454-68dc-4ff5-b89e-72ec89d4ce80'
            ConfigurationNames = @('Partial1','Partial2')
        }
        
        PartialConfiguration Partial1
        {
            Description = 'Place test1.txt at c:\'
            RefreshMode = 'Pull'
            ConfigurationSource = '[ConfigurationRepositoryWeb]PullServer'
        }

        PartialConfiguration Partial2
        {
            Description = 'Place test2.txt at c:\'
            RefreshMode = 'Pull'
            ConfigurationSource = '[ConfigurationRepositoryWeb]PullServer'
        }
    }

}

Where I'm having issues is with generating the mof for Partial1 and Partial2. Running this configuration will overwrite the file if there is exactly one mof in the .\Partial1 directory, but fails to output a mof if .\Partial1 contains 0, or 2 or more existing mofs.

Configuration Partial1
{
    node *
    {
        File test1
        {
            Ensure = 'Present'
            DestinationPath = 'c:\test1.txt'
            Contents = 'Content placed by Partial1'
        }
    }
}

May 10, 2016 at 6:24 am

Ah I see what you are saying. In the partial configurations I've written, I used the name of the Configuration (in your case "Partial1") as the name of the node. The value of node will determine the name of the .mof file.

Configuration Partial2 {

    Node ('Partial2') {            

        File Test {

            Ensure          = "Present"
            DestinationPath = "C:\some\path"
            Type            = "Directory"
        }             
        
                                  
    }
}

May 10, 2016 at 6:36 am

Hey that works. Thanks!

May 10, 2016 at 8:13 am

I stand corrected.
This is interesting and probably was fixed in latest version as it used to bug couple of months ago if you set ConfigurationNames to more then one value. I've opened a github issue and a uservoice on this and got a reply its not supported or intended to hold more then one value. So I left it be, hoping it wil be fixed at later point, but never read anything about this being fixed.

Probably it bugged as it was always from a single pullserver and not from multiple. Which was my ultimate request so I didn't have to setup multiple pull servers for four/five departments each in charge of their section.

The original blog is a good read on how he did it, indeed. Wonder what was the version of the xPSDesiredStateConfiguration module he used.

Phil, i would advise to use DependsOn on one of the partials just so you know exactly at what state the node is. Though it doesn't matter much with two files, but with complex scripts it becomes vital.

I would also advise on using a report server to see the combined actions.Here you will need another pull server just for that, no point building one for each of the partials.

Still think they should allow partials from same pullserver URL. One can only hope 😊 Good find Greg, thanks alot for sharing, need to test more scenarios then in my lab 😉

May 10, 2016 at 8:15 am

Don, if you're reading this, this needs to be pinned 😊