none
Powershell DSC - Get registry value and send $True / $False depending on present or not RRS feed

  • Question

  • Hello,

    With the script below, I can check if a registry key is present, and if it is not, it will create that registry key. But I just want to know if that registry key is present, and get $True / $False as a result of script. - Is this possible with DSC?

    Configuration ClientConfig
    {
    Param ($MachineName)
     
    Node $MachineName
        {
        Registry FooCorpReg1
            {
            Ensure = "Present"
            
            Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Test1"
            ValueName = "Name"
            ValueData = "DSCDemo"
            }
         
        }
    }
     
    # Save the MOF file
    ClientConfig -MachineName "localhost" -OutPutPath "c:\Temp\DSC" 
    
    #Start configuration
    Start-DscConfiguration -Path "C:\Temp\DSC\" -Wait -Verbose 

    Best regards,
    Anders Johansson

    Wednesday, November 12, 2014 4:03 PM

Answers

  • Not what DSC does or is for.  Use erg to look for vale.

    Test-Path HKLM:\SOFTWARE\Test1\Name

    That is all - it returns true or false.



    ¯\_(ツ)_/¯

    • Proposed as answer by jrvModerator Friday, November 14, 2014 5:28 PM
    • Marked as answer by AnnaWYModerator Wednesday, November 26, 2014 1:29 PM
    Wednesday, November 12, 2014 7:59 PM
    Moderator
  • No - that is not its purpose.  Why would you care.  DSC takes an end-state declaration and enforces it.  It is not a query tool.


    ¯\_(ツ)_/¯

    Thursday, November 13, 2014 9:50 AM
    Moderator

All replies

  • Not what DSC does or is for.  Use erg to look for vale.

    Test-Path HKLM:\SOFTWARE\Test1\Name

    That is all - it returns true or false.



    ¯\_(ツ)_/¯

    • Proposed as answer by jrvModerator Friday, November 14, 2014 5:28 PM
    • Marked as answer by AnnaWYModerator Wednesday, November 26, 2014 1:29 PM
    Wednesday, November 12, 2014 7:59 PM
    Moderator
  • Thank you for the reply!

    I know, but I just want to know if it is possible to use Powershell-DSC to achieve the same thing as "Test-Path". :)

    Regards
    Anders Johansson

    Thursday, November 13, 2014 8:08 AM
  • No - that is not its purpose.  Why would you care.  DSC takes an end-state declaration and enforces it.  It is not a query tool.


    ¯\_(ツ)_/¯

    Thursday, November 13, 2014 9:50 AM
    Moderator
  • Ok, thank you for the answer.
    Friday, November 14, 2014 9:39 AM