SRXEnv.psm1

if($Host.Name -like 'ScriptRunner Extended (SRX) PowerShell*Host'){
    throw "The SRXEnv module cannot be imported into a $($Host.Name)."
}

New-Variable -Name SRXEnv -Scope Global -Visibility Public -Description 'ScriptRunner host environment hashtable.' -Force

function Reset-SRXEnvironment
{
    <#
    .SYNOPSIS
    Reset global ScriptRunner PowerShell Host Environment Variable $SRXEnv.
    .DESCRIPTION
    Reset global ScriptRunner PowerShell Host Environment Variable $SRXEnv.
    #>

    [CmdletBinding()]
    param ()

    $me = whoami
    $ipaddress = '127.0.0.1'
    if(Get-Command -Name 'Get-NetIPAddress' -ErrorAction SilentlyContinue){
        $ipaddress = Get-NetIPAddress -AddressFamily IPv4 -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty 'IPAddress' -ErrorAction SilentlyContinue
    }

    $Global:SRXEnv = @{
        ReportEmail = ''
        ResultEmail = ''
        ResultList = New-Object -TypeName 'System.Collections.ArrayList'
        ResultList2 = New-Object -TypeName 'System.Collections.ArrayList'
        ResultMessage = ''
        ResultObjectJSON = $null
        SRXStarted = Get-Date
        SRXStartedBy = $me
        SRXStartedIP = $ipaddress
        SRXStartedVia = "Interactive by `"$($me)`" ($($Host.Name))"
    }
    Write-Verbose ($Global:SRXEnv | Out-String)
}

New-Alias -Name Reset-SRXEnv -Value Reset-SRXEnvironment -Scope Global -Option Constant, AllScope -Force

Reset-SRXEnvironment

Export-ModuleMember -Variable 'SRXEnv' -Function 'Reset-SRXEnvironment' -Alias 'Reset-SRXEnv'

# SIG # Begin signature block
# MIIa6wYJKoZIhvcNAQcCoIIa3DCCGtgCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCQaWHnjI34Ocv4
# G1Vj83gEbPGgeuTFQ/61M+POvXtDg6CCCWwwggSZMIIDg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