Custom DSC Reource - Test not returning Bool

Welcome Forums DSC (Desired State Configuration) Custom DSC Reource - Test not returning Bool

This topic contains 1 reply, has 1 voice, and was last updated by

 
Participant
3 months, 1 week ago.

  • Author
    Posts
  • #104438

    Participant
    Points: 0
    Rank: Member

    I have an issue with a Custom DSC I have written (my first attempt at such a thing – it just sets a wesite's ID).

    It is failing when I call it saying that "The PowerShell DSC resource returned results in a format that is not valid. The results from running Test-TargetResource must be the boolean value True or False."

    As far as I can see it is returning a bool – I have set verbose output which outputs:
    VERBOSE: [L0611755]: [[LBGSetWebsiteID]SetID] WEBSITE DOES EXIST
    VERBOSE: [L0611755]: [[LBGSetWebsiteID]SetID] Getting current ID
    VERBOSE: [L0611755]: [[LBGSetWebsiteID]SetID] CURRENT ID = 999
    VERBOSE: [L0611755]: [[LBGSetWebsiteID]SetID] CURRENT ID NOT THE SAME
    VERBOSE: [L0611755]: LCM: [ End Test ] [[LBGSetWebsiteID]SetID] in 0.4120 seconds.
    The PowerShell DSC resource returned results in a format that is not valid. The results from running
    Test-TargetResource must be the boolean value True or False.

    The last part of the code is:
    if($currentID -eq $newID)
    {
    Write-Verbose "CURRENT ID IS THE SAME AS NEW ID"
    Return $true
    }
    else
    {
    Write-Verbose "CURRENT ID NOT THE SAME"
    Return $false
    }

    Any idea what I am doing wrong? As far as I can see this MUST be returning a bool... clearly I've messed up somewhere, but can't see where.

  • #104447

    Participant
    Points: 0
    Rank: Member

    Issue resolved. I had an errant variable in the code that wasn't being set to anything. This caused the issue.

The topic ‘Custom DSC Reource - Test not returning Bool’ is closed to new replies.