Public/Save-LabRecipe.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function Save-LabRecipe
{
    [CmdletBinding(SupportsShouldProcess)]
    param
    (
        [Parameter(Mandatory, ValueFromPipeline)]
        [pscustomobject]
        $Recipe
    )

    $recipeFileName = Join-Path -Path $HOME -ChildPath "automatedLab\recipes\$($Recipe.Name).json"

    if ($PSCmdlet.ShouldProcess($recipeFileName, 'Storing recipe'))
    {
        $Recipe | ConvertTo-Json | Set-Content -Path $recipeFileName -NoNewline -Force
    }
}