AzStackHci.EnvironmentChecker.Reporting.psm1

<#
.SYNOPSIS
    Common Reporting functions across all modules/scenarios
.DESCRIPTION
    Logging, Reporting
.INPUTS
    Inputs (if any)
.OUTPUTS
    Output (if any)
.NOTES
    General notes
#>


function Set-AzStackHciOutputPath
{

    param ($Path, $Source='AzStackHciEnvironmentChecker/Diagnostic')
    if ([string]::IsNullOrEmpty($Path))
    {
        $Path = Join-Path -Path $HOME -ChildPath ".AzStackHci"
    }
    $Global:AzStackHciEnvironmentLogFile = Join-Path -Path $Path -ChildPath 'AzStackHciEnvironmentChecker.log'
    $Global:AzStackHciEnvironmentReport = Join-Path -Path $Path -ChildPath 'AzStackHciEnvironmentReport.json'
    $Global:AzStackHciEnvironmentReportXml = Join-Path -Path $Path -ChildPath 'AzStackHciEnvironmentReport.xml'
    Assert-EventLog -source $Source
    Set-AzStackHciIdentifier
}

Import-LocalizedData -BindingVariable lTxt -FileName AzStackHci.EnvironmentChecker.Strings.psd1

function Get-AzStackHciEnvProgress
{
    <#
    .SYNOPSIS
        Look for existing progress or create new progress.
    .DESCRIPTION
        Finds either the latest progress XML file or creates a new progress XML file
    .EXAMPLE
        PS C:\> <example usage>
        Explanation of what the example does
    .INPUTS
        Clean switch, in case the user wants to start fresh
        Path to search for progress run.
    .OUTPUTS
        PSCustomObject of progress.
    .NOTES
    #>

    param ([switch]$clean, $path = $PSScriptRoot)

    $latestReport = Get-Item -Path $Global:AzStackHciEnvironmentReportXml -ErrorAction SilentlyContinue
    if (-not $clean -and $latestReport)
    {
        $report = Import-Clixml $latestReport.FullName
        Log-Info -Message ('Found existing report: {0}' -f $report.FilePath) -Type Info
    }
    else
    {
        $hash = @{
            FilePath = $Global:AzStackHciEnvironmentReportXml
            Version  = $MyInvocation.MyCommand.Module.Version.ToString()
            Jobs     = @{}
        }
        $report = New-Object PSObject -Property $hash
        Log-Info -Message ('Creating new report {0}' -f $report.FilePath) -Type Info
    }
    $report
}

function Write-AzStackHciEnvProgress
{
    <#
    .SYNOPSIS
        Write report output to JSON
    .DESCRIPTION
        After all processing, take results object and convert to JSON report.
        Any file already existing will be overwritten.
    .EXAMPLE
        Write-AzStackHciEnvProgress -report $report
        Writes $report to JSON file
    .INPUTS
        [psobject]
    .OUTPUTS
        XML file on disk (path on disk is expected to be embedded in psobject)
    .NOTES
        General notes
    #>

    param ([psobject]$report)

    try
    {
        $report | Export-Clixml -Depth 10 -Path $report.FilePath -Force
        Log-Info -Message ('AzStackHCI progress written: {0}' -f $report.FilePath) -Type Info
    }
    Catch
    {
        Log-Info -Message ('Writing XML progress to disk error {0}' -f $_.exception.message) -Type Error
        throw $_.exception
    }
}

function Add-AzStackHciEnvJob
{
    <#
    .SYNOPSIS
        Adds a 'Job' to the progress object.
    .DESCRIPTION
        If a user runs the tool multiple time to check different assets
        e.g. Certificates on one execution and Registration details on the next execution
        Those executions are added to the progress for tracking purposes.
        Execution/Job details include:
            start time,
            parameters,
            parameterset (indicating what is being checked, certificates or Azure Accounts),
            Placeholders for EndTime and Duration (later filled in by Close-AzStackHciEnvJob)
    .EXAMPLE
        Add-AzStackHciEnvJob -report $report
        Adds execution job to progress object ($report)
    .INPUTS
        Report - psobject - containing all progress to date
    .OUTPUTS
        Report - psobject - updated with execution job log.
    .NOTES
        General notes
    #>

    param ($report)

    $allJobs = @{}
    $alljobs = $report.Jobs

    # Index for jobs must be a string for json conversion later
    if ($alljobs.Count)
    {
        $jobCount = ($alljobs.Count++).tostring()
    }
    else
    {
        $jobCount = '0'
    }

    # Record current job
    $currentJob = @{
        Index             = $jobCount
        StartTime         = (Get-Date -f 'yyyy/MM/dd HH:mm:ss')
        PSBoundParameters = (Get-PSCallStack).Command
        Operations        = (Get-PSCallStack).Arguments
        EndTime           = $null
        Duration          = $null
    }
    Log-Info -Message ('Adding current job to progress: {0}' -f $currentJob) -Type Info
    # Add current job
    $allJobs += @{"$jobcount" = $currentJob }
    $report.Jobs = $allJobs
    $report
}

function Close-AzStackHciEnvJob
{
    <#
    .SYNOPSIS
        Writes endtime and duration for jobs
    .DESCRIPTION
        Find latest job entry and update time and calculates duration
        calls function to update xml on disk
        and updates and returns report object
    .EXAMPLE
        Close-AzStackHciEnvJob -report $report
    .INPUTS
        Report - psobject - containing all progress to date
    .OUTPUTS
        Report - psobject - updated with finished execution job log.
    .NOTES
        General notes
    #>

    param ($report)

    try
    {
        $latestJob = $report.jobs.Keys -match '[0-9]' | ForEach-Object { [int]$_ } | Sort-Object -Descending | Select-Object -First 1
        $report.jobs["$latestJob"].EndTime = (Get-Date -f 'yyyy/MM/dd HH:mm:ss')
        $duration = (([dateTime]$report.jobs["$latestJob"].EndTime) - ([dateTime]$report.jobs["$latestJob"].StartTime)).TotalSeconds
        $report.jobs["$latestJob"].Duration = $duration
        Log-Info -Message ('Updating current job to progress with endTime: {0} and duration {1}' -f $report.jobs["$latestJob"].EndTime, $duration) -Type Info
    }
    Catch
    {
        Log-Info -Message ('Updating current job to progress failed with exception: {0}' -f $_.exception) -Type Error
        throw
    }
    Write-AzStackHciEnvProgress -report $report
    $report
}

function Write-AzStackHciEnvReport
{
    <#
    .SYNOPSIS
        Writes progress to disk in JSON format
    .DESCRIPTION
        Write progress object to disk in JSON format, overwriting as neccessary.
        The resulting blob is intended to be a portable record of what has been checked
        including the results of that check
    .EXAMPLE
        Write-AzStackHciEnvReport -report $report
    .INPUTS
        Report - psobject - containing all progress to date
    .OUTPUTS
        JSON - file - named AzStackEnvReport.json
    .NOTES
        General notes
    #>

    param ([psobject]$report)
    try
    {
        ConvertTo-Json -InputObject $report -Depth 8 -WarningAction SilentlyContinue | Out-File $AzStackHciEnvironmentReport -Force -Encoding UTF8
        Log-Info -Message ('JSON report written to {0}' -f $AzStackHciEnvironmentReport) -Type Info
    }
    catch
    {
        Log-Info -Message ('Writing JSON report failed:' -f $_.exception.message) -Type Error
        throw $_.exception
    }
}

function Log-Info
{
    <#
    .SYNOPSIS
        Write verbose logging to disk
    .DESCRIPTION
        Formats and writes verbose logging to disk under scriptroot. Log type (or severity) is essentially cosmetic
        to the verbose log file, no action should be inferred, such as termination of the script.
    .EXAMPLE
        Write-AzStackHciEnvironmentLog -Message ('Script messaging include data {0}' -f $data) -Type 'Info|Warning|Error' -Function 'FunctionName'
    .INPUTS
        Message - a string of the body of the log entry
        Type - a cosmetic type or severity for the message, must be info, warning or error
        Function - ideally the name of the function or the script writing the log entry.
    .OUTPUTS
        Appends Log entry to AzStackHciEnvironmentChecker.log under the script root.
    .NOTES
        General notes
    #>

    [cmdletbinding()]
    param(
        [string]
        $Message,

        [ValidateSet('Info', 'Warning', 'Error', 'Success')]
        [string]
        $Type = 'Info',

        [ValidateNotNullOrEmpty()]
        [string]$Function = ((Get-PSCallStack)[0].Command),

        [switch]$ConsoleOut,

        [switch]$Telemetry
    )
    $Message = RunMask $Message
    if ($ConsoleOut)
    {
        #if ($PSEdition -eq 'desktop')
        if ($true)
        {
            switch -wildcard ($function)
            {
                '*-AzStackHciEnvironment*' { $foregroundcolor = 'DarkYellow' }
                default { $foregroundcolor = "White" }
            }
            switch ($Type)
            {
                'Success' { $foregroundcolor = 'Green' }
                'Warning' { $foregroundcolor = 'Yellow' }
                'Error' { $foregroundcolor = 'Red' }
                default { $foregroundcolor = "White" }
            }
            Write-Host $message -ForegroundColor $foregroundcolor
        }
        else
        {
            Write-Host $message
        }
    }
    else
    {
        Write-Verbose $message
    }

    if (-not [string]::IsNullOrEmpty($message))
    {
        # Log to ETW
        if ($Telemetry)
        {
            $source = "AzStackHciEnvironmentChecker/Telemetry"
            $EventId = 17201
        }
        else
        {
            $source = "AzStackHciEnvironmentChecker/Operational"
            $EventId = 17203
        }
        $logName = 'AzStackHciEnvironmentChecker'
        $EventType = switch ($Type)
        {
            "Error" { "Error" }
            "Warning" { "Warning" }
            "Success" { "Information" }
            "Info" { "Information" }
            Default { "Information" }
        }

        # Only write telemetry or non-info entries to the eventlog to save time and noise.
        if ($Telemetry -or $EventType -ne "Information")
        {
            Write-ETWLog -Source $Source -logName $logName -Message $Message -EventType $EventType -EventId $EventId
        }
        # Log to file
        $entry = "[{0}] [{1}] [{2}] {3}" -f ([datetime]::now).tostring(), $type, $function, ($Message -replace "`n|`t", "")
        if (-not (Test-Path $AzStackHciEnvironmentLogFile))
        {
            New-Item -Path $AzStackHciEnvironmentLogFile -Force | Out-Null
        }
        $retries = 3
        for ($i = 1; $i -le $retries; $i++) {
            try {
                $entry | Out-File -FilePath $AzStackHciEnvironmentLogFile -Append -Force -Encoding UTF8
                $writeFailed = $false
                break
            }
            catch {
                $writeFailed = "Log-info $i/$retries failed: $($_.ToString())"
                start-sleep -Seconds 5
            }
        }
        if ($writeFailed)
        {
            throw $writeFailed
        }
    }
}

function RunMask
{
    [cmdletbinding()]
    [OutputType([string])]
    Param (
        [Parameter(ValueFromPipeline = $True)]
        [string]
        $in
    )
    Begin {}
    Process
    {
        try
        {
            <#$in | Get-PIIMask | Get-GuidMask#>
            $in | Get-GuidMask
        }
        catch
        {
            $_.exception
        }
    }
    End {}
}

function Get-PIIMask
{
    [cmdletbinding()]
    [OutputType([string])]
    Param (
        [Parameter(ValueFromPipeline = $True)]
        [string]
        $in
    )
    Begin
    {
        $pii = $($ENV:USERDNSDOMAIN), $($ENV:COMPUTERNAME), $($ENV:USERNAME), $($ENV:USERDOMAIN) | ForEach-Object {
            if ($null -ne $PSITEM)
            {
                $PSITEM
            }
        }
        $r = $pii -join '|'
    }
    Process
    {
        try
        {
            return [regex]::replace($in, $r, "[*redacted*]")
        }
        catch
        {
            $_.exception
        }
    }
    End {}
}

function Get-GuidMask
{
    [OutputType([string])]
    [CmdletBinding()]
    param (
        [Parameter(ValueFromPipeline = $True)]
        [String]
        $guid
    )
    Begin
    {
        $r = [regex]::new("(-([a-fA-F0-9]{4}-){3})")

    }
    Process
    {
        try
        {
            return [regex]::replace($guid, $r, "-xxxx-xxxx-xxxx-")
        }
        catch
        {
            $_.exception
        }
    }
    End {}
}

function Write-AzStackHciHeader
{
    <#
    .SYNOPSIS
        Write invocation and system information into log and writes cmdlet name and version to screen.
    #>

    param (
        [Parameter()]
        [System.Management.Automation.InvocationInfo]
        $invocation,

        [psobject]
        $params,

        [switch]
        $PassThru
    )
    try
    {
        $paramToString = ($params.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join ';'
        $cmdLetName = Get-CmdletName
        $cmdletVersion = (Get-Command $cmdletName -ErrorAction SilentlyContinue).version.tostring()
        Log-Info -Message ''
        Log-Info -Message ('{0} v{1} started.' -f `
                $cmdLetName, $cmdletVersion) `
            -ConsoleOut:(-not $PassThru)

        Log-Info -Telemetry -Message ('{0} started version: {1} with parameters: {2}. Id:{3}' `
                -f $cmdLetName, (Get-Module AzStackHci.EnvironmentChecker).Version.ToString(), $paramToString, $ENV:EnvChkrId)

        Log-Info -Message ('OSVersion: {0} PSVersion: {1} PSEdition: {2} Security Protocol: {3} Lanaguage Mode: {4}' -f `
                [environment]::OSVersion.Version.tostring(), $PSVersionTable.PSVersion.tostring(), $PSEdition, [Net.ServicePointManager]::SecurityProtocol, $ExecutionContext.SessionState.LanguageMode)
        Write-PsSessionInfo -params $params
    }
    catch
    {
        if (-not $PassThru)
        {
            Log-Info ("Unable to write header to screen. Error: {0}" -f $_.exception.message)
        }
    }
}

function Write-AzStackHciFooter
{
    <#
    .SYNOPSIS
        Writes report, log and cmdlet to screen.
    #>

    param (
        [Parameter()]
        [System.Management.Automation.InvocationInfo]
        $invocation,

        [switch]
        $failed,

        [switch]
        $PassThru
    )

    Log-Info -Message ("`nLog location: $AzStackHciEnvironmentLogFile") -ConsoleOut:(-not $PassThru)
    Log-Info -Message ("Report location: $AzStackHciEnvironmentReport") -ConsoleOut:(-not $PassThru)
    Log-Info -Message ("Use -Passthru parameter to return results as a PSObject.") -ConsoleOut:(-not $PassThru)
    if ($failed)
    {
        Log-Info -Message ("{0} failed" -f (Get-CmdletName)) -ConsoleOut:(-not $PassThru) -Type Error -Telemetry
    }
    else
    {
        Log-Info -Message ("{0} completed. Id:{1} " -f (Get-CmdletName),$ENV:EnvChkrId) -Telemetry
    }
}

function Get-CmdletName
{
    try
    {
        foreach ($c in (Get-PSCallStack).Command)
        {
            $functionCalled = Select-String -InputObject $c -Pattern "Invoke-AzStackHci(.*)Validation"
            if ($functionCalled)
            {
                 break
            }
        }
        $functionCalled
    }
    catch
    {
        throw "Hci Validation"
    }
}

function Write-AzStackHciResult
{
    <#
    .SYNOPSIS
        Displays results to screen
    .DESCRIPTION
        Displays test results to screen, highlighting failed tests.
    #>

    param (
        [Parameter()]
        [string]
        $Title,

        [Parameter()]
        [psobject]
        $result,

        $seperator = ' -> ',

        [switch]
        $Expand,

        [switch]
        $ShowFailedOnly
    )

    try
    {
        if (-not $result)
        {
            throw "Results missing. Ensure tests ran successfully."
        }
        Log-Info ("`n{0}:" -f $Title) -ConsoleOut


        foreach ($r in ($result | Sort-Object Status, Title, Description))
        {
            if ($r.status -ne 'Succeeded' -or $Expand)
            {
                Write-StatusSymbol -Status $r.Status -Severity $r.Severity
                Write-Host " " -NoNewline
                Write-Host @expandDownSymbol
                Write-Host " " -NoNewline
                if ($r.status -ne 'Succeeded')
                {
                    switch ($r.Severity)
                    {
                        Critical { Write-Host @needsRemediation }
                        Warning { Write-Host @needsAttention }
                        Informational { Write-Host @forInformation }
                        Default { Write-Host @Critical }
                    }
                }
                Write-Host " " -NoNewline
                Write-Host ($r.TargetResourceType + " - " + $r.Title + " " + $r.Description)
                foreach ($detail in ($r.AdditionalData | Sort-Object Status -Descending))
                {
                    if ($ShowFailedOnly -and $detail.Status -eq 'Succeeded')
                    {
                        continue
                    }
                    else
                    {
                        Write-Host " " -NoNewline
                        Write-StatusSymbol -Status $detail.Status -Severity $r.Severity
                        Write-Host " " -NoNewline
                        Write-Host " " -NoNewline
                        Write-Host ("{0}{1}{2}" -f $detail.Source, $seperator, $detail.Resource)
                    }
                }
                if ($detail.Status -ne 'Succeeded')
                {
                    Write-Host " " -NoNewline
                    Write-Host @helpSymbol
                    Write-Host (" Help URL: {0}" -f $r.Remediation)
                    Write-Host ""
                }
            }
            else
            {
                if (-not $ShowFailedOnly)
                {
                    Write-Host @expandOutSymbol
                    Write-Host " " -NoNewline
                    Write-Host @greenTickSymbol
                    Write-Host " " -NoNewline
                    Write-Host @isHealthy
                    Write-Host " " -NoNewline
                    Write-Host ($r.TargetResourceType + " " + $r.Title + " " + $r.Description)
                }
            }
        }
    }
    catch
    {
        Log-Info "Unable to write results. Error: $($_.exception.message)" -Type Warning
    }
}

function Write-ETWLog
{
    [CmdletBinding()]
    param (
        [Parameter()]
        [string]
        $source = 'AzStackHciEnvironmentChecker/Diagnostic',

        [Parameter()]
        [string]
        $logName = 'AzStackHciEnvironmentChecker',

        [Parameter(Mandatory = $true)]
        [string]
        $Message,

        [Parameter()]
        [string]
        $EventId = 0,

        [Parameter()]
        [string]
        $EventType = 'Information'
    )
    try
    {
        Write-EventLog -LogName $LogName -Source $Source -EntryType $EventType -Message $Message -EventId $EventId
    }
    catch
    {
        throw "Creating event log failed. Error $($_.exception.message)"
    }
}

function Assert-EventLog
{
    param (
        [Parameter()]
        [string]
        $source = 'AzStackHciEnvironmentChecker/Diagnostic'
    )
    try
    {
        $eventLog = Get-EventLog -LogName AzStackHciEnvironmentChecker -Source $Source -ErrorAction SilentlyContinue
    }
    catch {}
    # Try to create the log
    if (-not $eventLog)
    {
        New-AzStackHciEnvironmentCheckerLog
    }
}

function Write-ETWResult
{
    <#
    .SYNOPSIS
        Write result to telemetry channel
    #>

    [CmdletBinding()]
    param (
        [Parameter()]
        [psobject]
        $Result
    )

    try {
        $source = 'AzStackHciEnvironmentChecker/Telemetry'
        if (![string]::IsNullOrEmpty($ENV:EnvChkrId))
        {
            $Result | Add-Member -MemberType NoteProperty -Name 'HealthCheckSource' -Value $ENV:EnvChkrId -Force -ErrorAction SilentlyContinue
        }
        $Message = $Result | ConvertTo-Json -Depth 5
        $EventId = 17205
        $EventType = if ($Result.Status -ne 'Succeeded') { 'Warning' } else { 'Information' }
        Write-ETWLog -Source $Source -EventType $EventType -Message $Message -EventId $EventId

    }
    catch {
        Log-Info "Failed to write result to telemetry channel. Error: $($_.Exception.message)" -Type Warning
    }
}

function Get-AzStackHciEnvironmentCheckerEvents
{
    <#
    .SYNOPSIS
        Retrieve AzStackHCI Environment Checker events from event log
    .EXAMPLE
        Get-AzStackHciEnvironmentCheckerEvents -Verbose
        Retrieve AzStackHCI Environment Checker events from event log
    .EXAMPLE
        $results = Get-AzStackHciEnvironmentCheckerEvents | ? EventId -eq 17205 | Select -last 1 | Select -expand Message | Convertfrom-Json
        Write-AzStackHciResult -result $results
        Get last result and write to screen
    #>


    [CmdletBinding()]
    param (
        [Parameter()]
        [ValidateSet('Operational', 'Diagnostic', 'Telemetry')]
        [string]
        $Source
    )
    try
    {
        $sourceFilter = switch ($source)
        {
            Operational { "AzStackHciEnvironmentChecker/Operational" }
            Diagnostic { "AzStackHciEnvironmentChecker/Diagnostic" }
            Telemetry { "AzStackHciEnvironmentChecker/Telemetry" }
            Default { "*" }
        }
        try
        {
            Get-EventLog -LogName AzStackHciEnvironmentChecker -Source $SourceFilter
        }
        catch {}
    }
    catch
    {
        throw "Failed to retrieve AzStackHCI environment checker logs. Error: $($_.exception.message)"
    }
}

function New-AzStackHciEnvironmentCheckerLog
{
    try
    {
        $scriptBlock = {
            $logName = 'AzStackHciEnvironmentChecker'
            $sources = @('AzStackHciEnvironmentChecker/Operational', 'AzStackHciEnvironmentChecker/Diagnostic', 'AzStackHciEnvironmentChecker/Telemetry', 'AzStackHciEnvironmentChecker/RemoteSupport', 'AzStackHciEnvironmentChecker/StandaloneObservability')
            foreach ($source in $sources)
            {
                New-EventLog -LogName $logName -Source $Source -ErrorAction SilentlyContinue
                Limit-EventLog -LogName $logName -MaximumSize 250MB
                Write-EventLog -Message ('Initializing log provider {0}' -f $source) -EventId 0 -EntryType Information -Source $source -LogName $logName -ErrorAction Stop
            }
        }

        if (Test-Elevation)
        {
            Invoke-Command -ScriptBlock $scriptBlock
        }
        else
        {
            $psProcess = if (Join-Path -Path $PSHOME -ChildPath powershell.exe -Resolve -ErrorAction SilentlyContinue)
            {
                Join-Path -Path $PSHOME -ChildPath powershell.exe
            }
            elseif (Join-Path -Path $PSHOME -ChildPath pwsh.exe -Resolve -ErrorAction SilentlyContinue)
            {
                Join-Path -Path $PSHOME -ChildPath pwsh.exe
            }
            else
            {
                throw "Cannot find powershell process. Please run powershell elevated and run the following command: 'New-EventLog -LogName $logName -Source $sourceName'"
            }
            Write-Warning "We need to run an elevated process to register our event log. `nPlease continue and accept the UAC prompt to continue. `nAlternatively, run: `nNew-EventLog -LogName $logName -Source $source `nmanually and restart this command."
            if (Grant-UACConcent)
            {
                Start-Process $psProcess -Verb Runas -ArgumentList "-command (Invoke-Command -ScriptBlock {$scriptBlock})" -Wait
            }
            else
            {
                throw "Unable to elevate and register event log provider."
            }
        }
    }
    catch
    {
        throw "Failed to create Environment Checker log. Error: $($_.Exception.Message)"
    }
}

function Remove-AzStackHciEnvironmentCheckerEventLog
{
    <#
    .SYNOPSIS
        Remove AzStackHCI Environment Checker event log
    .EXAMPLE
        Remove-AzStackHciEnvironmentCheckerEventLog -Verbose
        Remove AzStackHCI Environment Checker event log
    #>

    [cmdletbinding()]
    param()
    Remove-EventLog -LogName "AzStackHciEnvironmentChecker"
}


function Grant-UACConcent
{
    $concentAnswered = $false
    $concent = $false
    while ($false -eq $concentAnswered)
    {
        $promptResponse = Read-Host -Prompt "Register the event log. (Y/N)"
        if ($promptResponse -imatch '^y$|^yes$')
        {
            $concentAnswered = $true
            $concent = $true
        }
        elseif ($promptResponse -imatch '^n$|^no$')
        {
            $concentAnswered = $true
            $concent = $false
        }
        else
        {
            Write-Warning "Unexpected response"
        }
    }
    return $concent
}

function Write-Summary
{
    param ($result, $property1, $property2, $property3, $seperator = '->')
    try
    {
        $summary = Get-Summary @PSBoundParameters

        # Write percentage
        Write-Host "`nSummary"
        Write-Host $lTxt.Summary
        if (-not ([string]::IsNullOrEmpty($summary.FailedResourceCritical)))
        {
            Write-Host " " -NoNewline
            Write-StatusSymbol -status 'Failed' -Severity Critical
            Write-Host (" {0} Critical Issue(s)" -f @($summary.FailedResourceCritical).Count)
        }

        if (-not ([string]::IsNullOrEmpty($summary.FailedResourceWarning)))
        {
            Write-Host " " -NoNewline
            Write-StatusSymbol -status 'Failed' -Severity Warning
            Write-Host (" {0} Warning Issue(s)" -f @($summary.FailedResourceWarning).Count)
        }

        if (-not ([string]::IsNullOrEmpty($summary.FailedResourceInformational)))
        {
            Write-Host " " -NoNewline
            Write-StatusSymbol -status 'Failed' -Severity Informational
            Write-Host (" {0} Informational Issue(s)" -f @($summary.FailedResourceInformational).Count)
        }

        if ($Summary.successCount -gt 0)
        {
            Write-Host " " -NoNewline
            Write-StatusSymbol -status 'Succeeded'
            Write-Host (" {0} successes" -f ($Summary.successCount))
        }

        <#Write-Host @expandDownSymbol
        Write-Host " " -NoNewline
        switch ($Severity)
        {
            'Critical' { Write-Host @redCrossSymbol }
            'Warning' { Write-Host @warningSymbol }
            Default { Write-Host @redCrossSymbol }
        }#>

        #Write-Host (" {0} / {1} ({2}%)" -f $summary.SuccessCount, $Result.AdditionalData.Resource.Count, $summary.SuccessPercentage)

        # Write issues by severity
        foreach ($severity in 'Critical', 'Warning', 'Informational')
        {
            $SeverityProp = "FailedResource{0}" -f $severity
            $failedResources = $summary.$SeverityProp | Sort-Object | Get-Unique

            if ($failedResources -gt 0)
            {
                Write-Host ""
                Write-Severity -severity $Severity
                Write-Host ""
                #Write-Host "`n$Severity Issues:"
                $failedResources | Sort-Object | Get-Unique | ForEach-Object {
                    Write-Host " " -NoNewline
                    switch ($Severity)
                    {
                        'Critical' { Write-Host @redCrossSymbol }
                        'Warning' { Write-Host @warningSymbol }
                        Default { Write-Host @redCrossSymbol }
                    }
                    Write-Host " $PSITEM"
                }
            }
        }

        if ($Summary.HelpLinks)
        {
            Write-Host "`nRemediation: "
            $Summary.HelpLinks | ForEach-Object {
                Write-Host " " -NoNewline
                Write-Host @helpSymbol
                Write-Host " $PSITEM"
            }
        }

        if (-not $summary.FailedResourceCritical -and -not $summary.FailedResourceWarning -and -not $summary.FailedResourceInformational)
        {
            Write-Host "`nSummary"
            Write-Host @expandOutSymbol
            Write-Host " " -NoNewline
            Write-Host @greenTickSymbol
            Write-Host (" {0} / {1} ({2}%) resources test successfully." -f $summary.SuccessCount, $Result.AdditionalData.Resource.Count, $summary.SuccessPercentage)
        }
    }
    catch
    {
        Log-Info -Message "Summary failed. $($_.Exception.Message)" -ConsoleOut -Type Warning
    }
}

function Get-Summary
{
    param ($result, $property1, $property2, $property3, $seperator = '->')

    try
    {
        if (-not $result)
        {
            throw "Unable to write summary. Check tests run successfully."
        }
        [array]$success = $result | Select-Object -ExpandProperty AdditionalData | Where-Object Status -EQ 'Succeeded'
        [array]$HelpLinks = $result | Where-Object Status -NE 'Succeeded' | Select-Object -ExpandProperty Remediation | Sort-Object | Get-Unique
        [array]$nonSuccess = $result | Select-Object -ExpandProperty AdditionalData | Where-Object Status -NE 'Succeeded'
        [array]$nonSuccessCritical = $result | Where-Object Severity -EQ Critical | Select-Object -ExpandProperty AdditionalData | Where-Object Status -NE 'Succeeded'
        [array]$nonSuccessWarning = $result | Where-Object Severity -EQ Warning | Select-Object -ExpandProperty AdditionalData | Where-Object Status -NE 'Succeeded'
        [array]$nonSuccessInformational = $result | Where-Object Severity -EQ Informational | Select-Object -ExpandProperty AdditionalData | Where-Object Status -NE 'Succeeded'

        $successPercentage = if ($success.count -gt 0)
        {
            [Math]::Round(($success.Count / $result.AdditionalData.Resource.count) * 100)
        }
        else
        {
            0
        }

        $sourceDestsb = {
            if ([string]::IsNullOrEmpty($_.$property2) -and [string]::IsNullOrEmpty($_.$property3))
            {
                "{0}" -f $_.$property1
            }
            elseif ([string]::IsNullOrEmpty($_.$property3))
            {
                "{0}{1}{2}" -f $_.$property1, $seperator, $_.$property2
            }
            else
            {
                "{0}{1}{2}({3})" -f $_.$property1, $seperator, $_.$property2, $_.$property3
            }
        }
        $FailedResourceCritical = $nonSuccessCritical |
        Select-Object @{ label = 'SourceDest'; Expression = $sourceDestsb } -ErrorAction SilentlyContinue |
        Select-Object -ExpandProperty SourceDest |
        Sort-Object |
        Get-Unique

        $FailedResourceWarning = $nonSuccessWarning |
        Select-Object @{ label = 'SourceDest'; Expression = $sourceDestsb } -ErrorAction SilentlyContinue |
        Select-Object -ExpandProperty SourceDest |
        Sort-Object |
        Get-Unique

        $FailedResourceInformational = $nonSuccessInformational |
        Select-Object @{ label = 'SourceDest'; Expression = $sourceDestsb } -ErrorAction SilentlyContinue |
        Select-Object -ExpandProperty SourceDest |
        Sort-Object |
        Get-Unique

        $summary = New-Object -Type PsObject -Property @{
            successCount                = $success.Count
            nonSuccessCount             = $nonSuccess.Count
            successPercentage           = $successPercentage
            HelpLinks                   = $HelpLinks
            FailedResourceCritical      = $FailedResourceCritical
            FailedResourceWarning       = $FailedResourceWarning
            FailedResourceInformational = $FailedResourceInformational
        }
        return $summary
    }
    catch
    {
        throw "Unable to calculate summary. Error $($_.exception.message)"
    }
}

# Symbols
$global:greenTickSymbol = @{
    Object          = [Char]0x2713     #8730
    ForegroundColor = 'Green'
    NoNewLine       = $true
}
$global:redCrossSymbol = @{
    Object          = [Char]0x2622 #0x00D7
    ForegroundColor = 'Red'
    NoNewLine       = $true
}

$global:WarningSymbol = @{
    Object          = [char]0x26A0
    ForegroundColor = 'Yellow'
    NoNewLine       = $true
}

$global:bulletSymbol = @{
    Object    = [Char]0x25BA
    NoNewLine = $true
}

# Text
$global:needsAttention = @{
    object          = $lTxt.NeedsAttention;
    ForegroundColor = 'Yellow'
    NoNewLine       = $true
}

$global:needsRemediation = @{
    object          = $lTxt.NeedsRemediation;
    ForegroundColor = 'Red'
    NoNewLine       = $true
}

$global:ForInformation = @{
    object    = $lTxt.ForInformation;
    NoNewLine = $true
}

$global:expandDownSymbol = @{
    object    = [Char]0x25BC # expand down
    NoNewLine = $true
}

$global:expandOutSymbol = @{
    object    = [Char]0x25BA # expand out
    NoNewLine = $true
}

$global:helpSymbol = @{
    object    = [char]0x270E   #0x263C # sunshine
    NoNewLine = $true
    #ForegroundColor = 'Yellow'
}

$global:Critical = @{
    object          = $lTxt.Critical;
    ForegroundColor = 'Red'
    NoNewLine       = $true
}

$global:Warning = @{
    object          = $lTxt.Warning;
    ForegroundColor = 'Yellow'
    NoNewLine       = $true
}

$global:Information = @{
    object    = $lTxt.Informational;
    NoNewLine = $true
}

$global:isHealthy = @{
    object    = $lTxt.Healthy
    NoNewLine = $true
}

function Write-StatusSymbol
{
    param ($status, $severity)
    switch ($status)
    {
        "Succeeded" { Write-Host @greenTickSymbol }
        "Failed"
        {
            switch ($Severity)
            {
                'Critical' { Write-Host @redCrossSymbol }
                'Warning' { Write-Host @warningSymbol }
                Default { Write-Host @redCrossSymbol }
            }
        }
        Default { Write-Host @bulletSymbol }
    }
}

function Write-Severity
{
    param ($severity)
    switch ($severity)
    {
        'Critical' { Write-Host @needsRemediation }
        'Warning' { Write-Host @needsAttention }
        'Informational' { Write-Host @ForInformation }
        Default { Write-Host @Critical }
    }
}

function Set-AzStackHciIdentifier
{
    $ENV:EnvChkrId = $null
    if ([string]::IsNullOrEmpty($ENV:EnvChkrOp))
    {
        $ENV:EnvChkrOp = 'Manual'
    }
    $validatorCmd = Get-CmdletName
    if(-not [string]::IsNullOrWhiteSpace($validatorCmd))
    {
        $ENV:EnvChkrId = "{0}\{1}\{2}" -f $ENV:EnvChkrOp, $validatorCmd.matches.groups[1], (([system.guid]::newguid()) -split '-' | Select-Object -first 1)
    }
}

function Write-PsSessionInfo
{
    <#
    .SYNOPSIS
        Write some pertainent information to the log about any PsSessions passed
    #>

    [CmdletBinding()]
    param (
        $params
    )
    try {
        if ($params['PsSession'])
        {
            foreach ($session in $params['PsSession'])
            {
                Log-Info -Message ("PsSession info: {0}, {1}, {2}, {3}, {4}, {5}" -f $session.ComputerName, $session.Name, $session.Id, $session.Runspace.ConnectionInfo.credential.username, $session.Runspace.SessionStateProxy.LanguageMode, $session.Runspace.ConnectionInfo.AuthenticationMechanism)
            }
        }
        else
        {
            Log-Info -Message "No PsSession info to write"
        }
    }
    catch
    {
        Log-Info -Message "Failed to write PsSession info: $($_.exception.message)"
    }
}

Export-ModuleMember -function Add-AzStackHciEnvJob
Export-ModuleMember -function Close-AzStackHciEnvJob
Export-ModuleMember -function Get-AzStackHciEnvironmentCheckerEvents
Export-ModuleMember -function Get-AzStackHciEnvProgress
Export-ModuleMember -function Log-Info
Export-ModuleMember -function Set-AzStackHciOutputPath
Export-ModuleMember -function Write-AzStackHciEnvReport
Export-ModuleMember -function Write-AzStackHciFooter
Export-ModuleMember -function Write-AzStackHciHeader
Export-ModuleMember -function Write-AzStackHciResult
Export-ModuleMember -function Write-ETWLog
Export-ModuleMember -function Write-ETWResult
Export-ModuleMember -function Write-Summary

# SIG # Begin signature block
# MIInpAYJKoZIhvcNAQcCoIInlTCCJ5ECAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDwchVxhlvOXpzQ
# 16+SkR2CZVcob3Yi251rC71GPBvSiaCCDYUwggYDMIID66ADAgECAhMzAAADTU6R
# phoosHiPAAAAAANNMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p
# bmcgUENBIDIwMTEwHhcNMjMwMzE2MTg0MzI4WhcNMjQwMzE0MTg0MzI4WjB0MQsw
# CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9u
# ZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF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