Microsoft.SpringboardTest.DSC.psm1

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

#Requires -RunAsAdministrator

using namespace System.Collections.Generic
using namespace System.Diagnostics

[DSCResource()]
class SBcliCookRecipe
{
    [DscProperty(Mandatory)]
    [string]$library

    [DscProperty(Key)]
    [string]$recipe

    [DscProperty()]
    [string]$predefinedOutputs

    # Get
    [SBcliCookRecipe] Get()
    {
        return @{
            library = $this.library
            recipe = $this.recipe
            predefinedOutputs = $this.predefinedOutputs
        }
    }

    # Test
    [bool] Test()
    {
        # Always execute
        return $false
    }

    # Set
    [void] Set()
    {
        try {
            $ErrorActionPreference = 'Stop'
            Set-ExecutionPolicy Bypass -Scope Process -Force;
            pwsh C:\ES.DevProd\SpringBoard\Sbcli-Task\sbcli-invoke.ps1 -UserPredefinedOutputsFilePath "$($this.predefinedOutputs)" -Environment PPE --SpringBoardTriggerRecipe "$($this.recipe)"
        }
        catch {
            throw("Failed to execute Springboard $this.recipe recipe. LASTEXITCODE = $LASTEXITCODE, Exception = $($_.Exception)")
        }
    }
}