First Config - DSC, PSTools

Welcome Forums DSC (Desired State Configuration) First Config - DSC, PSTools

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
3 months, 1 week ago.

  • Author
    Posts
  • #105929

    Participant
    Points: 0
    Rank: Member

    Watching some vids on DSC and seeing what I can try. How's this look for a first config file? Am I on the right track? The intent of the file would be to make sure PSTools and its contents are where they belong on a system and, if not, put them there and then to also ensure that the PSTools path is available in the PATH variable.

    Configuration TechResources
    {
        param (
            [parameter(mandatory)]
            [validateNullorEmpty()]
            [string[]]$NodeName
        )
        Node AComputer
        {
            File $NodeName
            {
                Ensure="Present"
                DestinationPath = "c:\Program Files (x86)\PSTools"
                Recurse = True
                Type = Directory 
                SourcePath = FileSystem::"\\SOMESERVERNAME\PSTools"
            }
            Environment $NodeName
            {
                Ensure="Present"
                Name = "c:\Program Files (x86)\PSTools"
            }
        }
    }
    TechResources
    
  • #105991

    Keymaster
    Points: 1,638
    Helping HandTeam Member
    Rank: Community Hero

    I'm not sure I'd use the node name as the unique identifier for each configuration element. It seems like you'd use the $NodeName in place of "AComputer," unless you're looking specifically to configure a machine named ACOMPUTER.

    The Environment resource is for configuring environment variables. I'm not sure what your intent is in using it the way you are. Seems like you'd want to configure the PATH variable to include a specific value, and you'd include the Path setting as $True to ensure your value is concatenated. Docs on that resource are at https://docs.microsoft.com/en-us/powershell/dsc/environmentresource.

  • #107765

    Participant
    Points: 587
    Helping Hand
    Rank: Major Contributor

    As Don mentioned, $NodeName will be ideally used for naming Node function and not as unique identifier for each configuration element. There won't be much advantage of making identifier for each configuration element dynamic.

  • #108292

    Participant
    Points: 0
    Rank: Member

    Thank you both for taking the time to answer.  Yes, the $nodeName was just me not getting it and putting it entirely in the wrong place.  It did go in place of AComputer.  I also did get the environmental path variable to play nice.

    But I guess I'm left wondering what's the value of DSC over just having a regular, PoSH script doing the same thing.  I can check if something exists and install if it does not and I can check that environmental variables exist and correct if they do not without having to learn/work through this very different format of doing things.

    Can't I just stand up a system and run a standard PowerShell script against it to configure everything just the same?  Please help me understand the differing value of DSC over other methods or, if you could/would, point me to resources that can go deeper on this matter?

    Thank you!

The topic ‘First Config - DSC, PSTools’ is closed to new replies.