Using env variables within Registry resoucre

Welcome Forums DSC (Desired State Configuration) Using env variables within Registry resoucre

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

 
Participant
4 years, 3 months ago.

  • Author
    Posts
  • #18105

    Participant
    Points: 0
    Rank: Member

    I am trying to set registry values using the registry resource within DSC. The problem I am running into is the “ValueData” field needs to be the remote nodes hostname, but when the DSC client pulls down those settings it applies the DSC Pull server's hostname instead.

    Sample of my script is below:

    Registry AltDefaultUserName {
    Ensure = "Present"
    Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
    ValueName = "AltDefaultUserName"
    ValueData = "$env:COMPUTERNAME"
    Force = 'True'
    }

    I would like to keep this variable as I am applying this DSC setup to many devices.

    Thanks,

    Kyle

  • #18115

    Member
    Points: 0
    Rank: Member

    Kyle,

    The problem you're having is that the computer that compiles the mof will be the one supplying the $env:computername variable. Consider Using the -ConfigurationData parameter to supply that info to your build.

  • #18132

    Participant
    Points: 0
    Rank: Member

    That worked! Thanks Jason.

The topic ‘Using env variables within Registry resoucre’ is closed to new replies.