Functions/Get-BT_RunbookEnvironment.ps1

<#
.SYNOPSIS
    This function retrieves the current BitTitan Runbook environment.
#>

function Get-BT_RunbookEnvironment {
    # Create an object to store the settings
    $environment = [PSCustomObject]@{
        PSTypeName = "BitTitan.RunbookEnvironment"
    }

    # Retrieve the environment settings
    if ($Global:PSDefaultParameterValues.ContainsKey("*-BT_*:Environment")) {
        $environment | Add-Member -NotePropertyName "Environment" -NotePropertyValue $Global:PSDefaultParameterValues["*-BT_*:Environment"]
    }
    else {
        $environment | Add-Member -NotePropertyName "Environment" -NotePropertyValue "Beta"
    }
    if ($Global:PSDefaultParameterValues.ContainsKey("*-BT_*:IsRunningOnLocalMachine")) {
        $environment | Add-Member -NotePropertyName "IsRunningOnLocalMachine" -NotePropertyValue $Global:PSDefaultParameterValues["*-BT_*:IsRunningOnLocalMachine"]
    }
    else {
        $environment | Add-Member -NotePropertyName "IsRunningOnLocalMachine" -NotePropertyValue $false
    }
    if ($Global:PSDefaultParameterValues.ContainsKey("*-BT_*:IsTestEnvironment")) {
        $environment | Add-Member -NotePropertyName "IsTestEnvironment" -NotePropertyValue ($Global:PSDefaultParameterValues["*-BT_*:IsTestEnvironment"])
    }
    else {
        $environment | Add-Member -NotePropertyName "IsTestEnvironment" -NotePropertyValue $false
    }

    # Set the environment to ensure that defaults are set
    Set-BT_RunbookEnvironment -Environment $environment.Environment `
        -IsRunningOnLocalMachine $environment.IsRunningOnLocalMachine `
        -IsTestEnvironment $environment.IsTestEnvironment

    # Return the object containing the settings
    return $environment
}