AzStackHciUpgrade/AzStackHci.Upgrade.Helpers.psm1

Import-LocalizedData -BindingVariable luTxt -FileName AzStackHci.Upgrade.Strings.psd1
Import-Module $PSScriptRoot\..\AzStackHciHardware\AzStackHci.Hardware.Helpers.psm1 -Force -DisableNameChecking -Global


function Test-23H2
{
    <#
    .SYNOPSIS
        Test Windows OS is 23H2
    .DESCRIPTION
        Test Windows OS is 23H2
    .EXAMPLE
        PS C:\> Test-23H2
        Test Windows OS is 23H2 on localhost.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try
    {
        Import-Module "$PsScriptRoot\..\AzStackHciSoftware\AzStackHci.Software.Helpers.psm1" -Force
        # 23H2 greater and equal 8B (do 6B for now)
        $instanceResults = Test-OSVersion -PsSession $PsSession -MinimumVersion '10.0.25398.887'
        foreach ($instanceResult in $instanceResults)
        {
            $instanceResult.Name = 'AzStackHci_Upgrade_23H2'
            $instanceResult.Title = 'Test Windows OS is 23H2'
            $instanceResult.DisplayName = 'Test Windows OS is 23H2'
            $instanceResult.Description = 'Checking Windows OS is 23H2'
            $instanceResult.Tags = @{}
            $instanceResult.Severity = 'CRITICAL'
            $instanceResult.Remediation = 'https://learn.microsoft.com/en-us/azure-stack/hci/deploy/deployment-tool-install-os'
            $instanceResult.TargetResourceID = $instanceResult.TargetResourceName
            $instanceResult.TargetResourceType = 'OS'
            $instanceResult.HealthCheckSource = $ENV:EnvChkrId
        }
        return $instanceResults
    }
    catch
    {
        throw $_
    }

}

function Test-HciCluster
{
    <#
    .SYNOPSIS
        Test all nodes are part of the same cluster, nodes are up and cluster is not stretched
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try
    {
        $remoteOutput = @()
        $sb = {
            $clusterName = ""
            try {
                $clusterName = Get-Cluster | Select-Object -Expand Name
                # omitting -Cluster as this requires CredSSP
                $clusterNodes = Get-ClusterNode
                $clusterFaultDomainSiteName = Get-ClusterFaultDomain -Type Site | Select-Object -Expand Name
            }
            catch{}
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                Cluster = $clusterName
                ClusterNodes = $clusterNodes
                ClusterFaultDomain = $clusterFaultDomainSiteName
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }

        $instanceResults = @()
        # Check cluster exists
        foreach ($output in $remoteOutput)
        {
            if ([string]::IsNullOrEmpty($output.Cluster))
            {
                $status = 'FAILURE'
                $detail = $luTxt.NoClusterFound -f $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }
            else
            {
                $status = 'SUCCESS'
                $detail = $luTxt.ClusterFound -f $output.ComputerName, $output.Cluster
                Log-Info $detail
            }

            $params = @{
                Name               = 'AzStackHci_Upgrade_Cluster_Exists'
                Title              = 'Test Cluster Exists'
                DisplayName        = 'Test Cluster Exists'
                Severity           = 'CRITICAL'
                Description        = 'Checking Cluster is installed'
                Tags               = @{}
                Remediation        = 'https://learn.microsoft.com/en-us/azure-stack/hci/deploy/deployment-tool-install-os'
                TargetResourceID   = $output.ComputerName
                TargetResourceName = $output.ComputerName
                TargetResourceType = 'Cluster'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'Cluster'
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }

        # Check all nodes part of same cluster
        # ensure all cluster nodes are part of the same cluster
        if (($remoteOutput.Cluster | Sort-Object | Get-Unique).Count -eq 1)
        {
            $status = 'SUCCESS'
            Log-Info $detail
        }
        else
        {
            $status = 'FAILURE'
            Log-Info $detail -Type CRITICAL
        }

        $params = @{
            Name               = 'AzStackHci_Upgrade_AllNodesInSameCluster'
            Title              = 'Test All Nodes in Same Cluster'
            DisplayName        = 'Test All Nodes in Same Cluster'
            Severity           = 'CRITICAL'
            Description        = 'Checking all nodes are part of the same cluster'
            Tags               = @{}
            Remediation        = 'https://aka.ms/UpgradeRequirements'
            TargetResourceID   = 'Cluster'
            TargetResourceName = 'Cluster'
            TargetResourceType = 'Cluster'
            Timestamp          = [datetime]::UtcNow
            Status             = $status
            AdditionalData     = @{
                Source    = 'Cluster'
                Resource  = 'Cluster'
                Detail    = $detail
                Status    = $status
                TimeStamp = [datetime]::UtcNow
            }
            HealthCheckSource  = $ENV:EnvChkrId
        }

        $instanceResults += New-AzStackHciResultObject @params

        # Return if there is a failure at this point
        if ('FAILURE' -in $instanceResults.Status)
        {
            return $instanceResults
        }
        else
        {
            # Test all nodes are up
            Log-Info "Cluster Nodes:"
            Log-Info ($remoteOutput.ClusterNodes | Out-String)
            foreach ($node in $remoteOutput[0].ClusterNodes)
            {
                if ($node.State -ne 'Up')
                {
                    $status = 'FAILURE'
                    $detail = "Node $($node.Name) is not in 'Up' state."
                    Log-Info $detail -Type CRITICAL
                }
                else
                {
                    $status = 'SUCCESS'
                    $detail = "Node $($node.Name) is in 'Up' state."
                    Log-Info $detail
                }
                $params = @{
                    Name               = 'AzStackHci_Upgrade_ClusterNodeUp'
                    Title              = 'Test Cluster Node is up'
                    DisplayName        = "Test Cluster Node is up $($node.Name)"
                    Severity           = 'CRITICAL'
                    Description        = 'Checking cluster node is up'
                    Tags               = @{}
                    Remediation        = 'https://aka.ms/UpgradeRequirements'
                    TargetResourceID   = $node.Name
                    TargetResourceName = $node.Name
                    TargetResourceType = 'ClusterNode'
                    Timestamp          = [datetime]::UtcNow
                    Status             = $status
                    AdditionalData     = @{
                        Source    = 'Cluster'
                        Resource  = 'ClusterNode'
                        Detail    = $detail
                        Status    = $status
                        TimeStamp = [datetime]::UtcNow
                    }
                    HealthCheckSource  = $ENV:EnvChkrId
                }
                $instanceResults += New-AzStackHciResultObject @params
            }
        }

        # Make sure cluster is not stretched

        if (($output.ClusterFaultDomain | Sort-Object | Get-Unique).Count -gt 1)
        {
            $status = 'FAILURE'
            $detail = $luTxt.StretchedClusterEnabled -f $output.Cluster
            Log-Info $detail -Type CRITICAL
        }
        else
        {
            $status = 'SUCCESS'
            $detail = $luTxt.StretchedClusterNotEnabled -f $output.Cluster
            Log-Info $detail
        }

        $params = @{
            Name               = 'AzStackHci_Upgrade_StretchedCluster'
            Title              = 'Test Stretched Cluster'
            DisplayName        = 'Test Stretched Cluster'
            Severity           = 'CRITICAL'
            Description        = 'Checking Stretched Cluster is enabled'
            Tags               = @{}
            Remediation        = 'https://aka.ms/UpgradeRequirements'
            TargetResourceID   = $output.ComputerName
            TargetResourceName = $output.ComputerName
            TargetResourceType = 'Cluster'
            Timestamp          = [datetime]::UtcNow
            Status             = $status
            AdditionalData     = @{
                Source    = $output.ComputerName
                Resource  = 'Stretched Cluster'
                Detail    = $detail
                Status    = $status
                TimeStamp = [datetime]::UtcNow
            }
            HealthCheckSource  = $ENV:EnvChkrId
        }
        $instanceResults += New-AzStackHciResultObject @params
        return $instanceResults
    }
    catch
    {
        throw $_
    }
}

function Test-RequiredWindowsFeature
{
    <#
    .SYNOPSIS
        Test if the required Windows feature is installed
    .DESCRIPTION
        Test if the required Windows feature is installed
    .EXAMPLE
        PS C:\> Test-RequiredWindowsFeature
        Test if the required Windows feature is installed on localhost.
    .EXAMPLE
        PS C:\> $Credential = Get-Credential -Message "Credential for $RemoteSystem"
        PS C:\> $RemoteSystemSession = New-PSSession -Computer
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try
    {
        $remoteOutput = @()
        $sb = {
            # Can be dedup with windowsOptionalFeatureToCheck
            $windowsFeatureTocheck =  @(
                "Failover-Clustering",
                "NetworkATC",
                "RSAT-AD-Powershell",
                "RSAT-Hyper-V-Tools",
                "Data-Center-Bridging",
                "NetworkVirtualization",
                "RSAT-AD-AdminCenter"
            )
            $windowsOptionalFeatureToCheck = @(
                "Server-Core",
                "ServerManager-Core-RSAT",
                "ServerManager-Core-RSAT-Role-Tools",
                "ServerManager-Core-RSAT-Feature-Tools",
                "DataCenterBridging-LLDP-Tools",
                "Microsoft-Hyper-V",
                "Microsoft-Hyper-V-Offline",
                "Microsoft-Hyper-V-Online",
                "RSAT-Hyper-V-Tools-Feature",
                "Microsoft-Hyper-V-Management-PowerShell",
                "NetworkVirtualization",
                "RSAT-AD-Tools-Feature",
                "RSAT-ADDS-Tools-Feature",
                "DirectoryServices-DomainController-Tools",
                "ActiveDirectory-PowerShell",
                "DirectoryServices-AdministrativeCenter",
                "DNS-Server-Tools",
                "EnhancedStorage",
                "WCF-Services45",
                "WCF-TCP-PortSharing45",
                "NetworkController",
                "NetFx4ServerFeatures",
                "NetFx4",
                "MicrosoftWindowsPowerShellRoot",
                "MicrosoftWindowsPowerShell",
                "Server-Psh-Cmdlets",
                "KeyDistributionService-PSH-Cmdlets",
                "TlsSessionTicketKey-PSH-Cmdlets",
                "Tpm-PSH-Cmdlets",
                "FSRM-Infrastructure",
                "ServerCore-WOW64",
                "SmbDirect",
                "FailoverCluster-AdminPak",
                "Windows-Defender",
                "SMBBW",
                "FailoverCluster-FullServer",
                "FailoverCluster-PowerShell",
                "Microsoft-Windows-GroupPolicy-ServerAdminTools-Update",
                "DataCenterBridging",
                "BitLocker",
                "FileServerVSSAgent",
                "FileAndStorage-Services",
                "Storage-Services",
                "File-Services",
                "CoreFileServer",
                "SystemDataArchiver",
                "ServerCoreFonts-NonCritical-Fonts-MinConsoleFonts",
                "ServerCoreFonts-NonCritical-Fonts-BitmapFonts",
                "ServerCoreFonts-NonCritical-Fonts-TrueType",
                "ServerCoreFonts-NonCritical-Fonts-UAPFonts",
                "ServerCoreFonts-NonCritical-Fonts-Support",
                "ServerCore-Drivers-General",
                "ServerCore-Drivers-General-WOW64",
                "NetworkATC"
            )
            $windowsFeatureNotInstalled = @()
            foreach ($featureName in $windowsFeatureToCheck)
            {
                if (-not (Get-WindowsFeature -Name $featureName | Where-Object InstallState -eq Installed))
                {
                    $windowsFeatureNotInstalled += $featureName
                }
            }
            $windowsOptionalFeatureNotEnabled = @()
            foreach ($featureName in $windowsOptionalFeatureToCheck)
            {
                if (-not (Get-WindowsOptionalFeature -Online -FeatureName $featureName | Where-Object State -eq Enabled))
                {
                    $windowsOptionalFeatureNotEnabled += $featureName
                }
            }
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                list = $windowsFeatureNotInstalled + $windowsOptionalFeatureNotEnabled
                result = ($windowsFeatureNotInstalled.Count -eq 0) -and ($windowsOptionalFeatureNotEnabled.Count -eq 0)
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }

        $instanceResults = @()
        foreach ($output in $remoteOutput)
        {
            if ($output.result)
            {
                $status = 'SUCCESS'
                $detail = $luTxt.RequiredWindowsFeatureEnabled -f $output.ComputerName
                Log-Info $detail
            }
            else
            {
                $status = 'FAILURE'
                $featureList = ($output.list) -join ', '
                $detail = $luTxt.RequiredWindowsFeatureNotEnabled -f $featureList, $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }

            $params = @{
                Name               = 'AzStackHci_Required_Windows_Features'
                Title              = 'Test Required Windows features'
                DisplayName        = 'Test Required Windows features'
                Severity           = 'Critical'
                Description        = 'Checks that all nodes have the required Windows features installed'
                Tags               = @{}
                Remediation        = "https://aka.ms/UpgradeRequirements"
                TargetResourceID   = $output.ComputerName
                TargetResourceName = $output.ComputerName
                TargetResourceType = 'Feature'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'Required Windows features '
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }
        return $instanceResults
    }
    catch
    {
        throw $_
    }

}

function Test-NetworkAtcIntents
{
    <#
    .SYNOPSIS
        Test the required Network ATC intents are present and in heathy state
    .DESCRIPTION
        Test the required Network ATC intents are present and in heathy state
    .EXAMPLE
        PS C:\> Test-NetworkAtcIntents
        Test the required Network ATC intents are present and in heathy state.
    .EXAMPLE
        PS C:\> $Credential = Get-Credential -Message "Credential for $RemoteSystem"
        PS C:\> $RemoteSystemSession = New-PSSession -Computer
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try
    {
        $remoteOutput = @()
        $sb = {
            $networkATC = [bool](Get-WindowsFeature -Name NetworkATC | Where-Object InstallState -eq 'Installed')
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                result = $networkATC
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }

        $hasError = $false
        $instanceResults = @()
        foreach ($output in $remoteOutput)
        {
            if ($output.result)
            {
                $status = 'SUCCESS'
                $detail = $luTxt.NetworkAtcEnabled -f $output.ComputerName
                Log-Info $detail
            }
            else
            {
                $status = 'FAILURE'
                $hasError = $true
                $detail = $luTxt.NetworkAtcNotEnabled -f $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }

            $params = @{
                Name               = 'AzStackHci_Upgrade_Test_NetworkATCFeature_Installed'
                Title              = 'Test Network ATC feature is installed on the node'
                DisplayName        = 'Test Network ATC feature is installed on the node'
                Severity           = 'CRITICAL'
                Description        = 'Checking Network ATC feature is enabled on the node'
                Tags               = @{}
                Remediation        = 'https://aka.ms/UpgradeNetworkATC'
                TargetResourceID   = 'NetworkAtcFeature'
                TargetResourceName = 'NetworkAtcFeature'
                TargetResourceType = 'NetworkAtcFeature'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'Network ATC'
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }

        # If there is a node that doesn't have Network ATC enabled, then the cluster won't have proper network ATC intents configured. So no need to check further.
        if ($hasError)
        {
            return $instanceResults
        }

        # Check if the Network ATC service is running on the nodes
        $remoteOutput = @()
        $sb = {
            $atcService = Get-Service NetworkATC -ErrorAction SilentlyContinue
            $atcServiceRunning = $atcService -and $atcService.Status -eq [System.ServiceProcess.ServiceControllerStatus]::Running
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                result = $atcServiceRunning
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }

        foreach ($output in $remoteOutput)
        {
            if ($output.result)
            {
                $status = 'SUCCESS'
                $detail = $luTxt.NetworkAtcServiceRunning -f $output.ComputerName
                Log-Info $detail
            }
            else
            {
                $status = 'FAILURE'
                $detail = $luTxt.NetworkAtcServiceNotRunning -f $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }

            $params = @{
                Name               = 'AzStackHci_Upgrade_Test_NetworkATCService_Running'
                Title              = 'Test NetworkATC service is running on the node'
                DisplayName        = 'Test NetworkATC service is running on the node'
                Severity           = 'CRITICAL'
                Description        = 'Checking NetworkATC service is running on the node'
                Tags               = @{}
                Remediation        = 'Make sure NetworkAtc service is running on the node. If not, start the service.'
                TargetResourceID   = 'NetworkAtcService'
                TargetResourceName = 'NetworkAtcService'
                TargetResourceType = 'NetworkAtcService'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'Network ATC'
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }

        # Check if the required Network ATC intents are present
        $remoteOutput = @()
        $sb = {
            $intents = Get-NetIntent -ErrorAction SilentlyContinue
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                result = $intents
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }

        $clusterNodesCount = (Get-ClusterNode).Count
        foreach ($output in $remoteOutput)
        {
            if ($null -eq $output.result)
            {
                $status = 'FAILURE'
                $detail = $luTxt.NetworkAtcIntentsNotPresent -f $output.ComputerName
                Log-Info $detail -Type CRITICAL

                $params = @{
                    Name               = 'AzStackHci_Upgrade_Test_NetworkATCIntents_Present'
                    Title              = 'Test NetworkATC intents are present on the node'
                    DisplayName        = 'Test NetworkATC intents are present on the node'
                    Severity           = 'CRITICAL'
                    Description        = 'Checking NetworkATC intents are present on the node'
                    Tags               = @{}
                    Remediation        = 'Make sure NetworkATC intents are properly configured on the node.'
                    TargetResourceID   = 'NetworkAtcIntents'
                    TargetResourceName = 'NetworkAtcIntents'
                    TargetResourceType = 'NetworkAtcIntents'
                    Timestamp          = [datetime]::UtcNow
                    Status             = $status
                    AdditionalData     = @{
                        Source    = $output.ComputerName
                        Resource  = 'Network ATC'
                        Detail    = $detail
                        Status    = $status
                        TimeStamp = [datetime]::UtcNow
                    }
                    HealthCheckSource  = $ENV:EnvChkrId
                }
                $instanceResults += New-AzStackHciResultObject @params
            }
            else
            {
                $outputResultString = $output.result | Out-String
                log-info "Get-NetIntent returned from node $($output.ComputerName) : $outputResultString"

                $isManagementIntentPresent = $output.result | Where-Object { $_.IsManagementIntentSet -eq $true }
                $isStorageIntentPresent = $output.result | Where-Object { $_.IsStorageIntentSet -eq $true }

                if (-not $isManagementIntentPresent)
                {
                    $status = 'FAILURE'
                    $detail = $luTxt.NetworkAtcManagementIntentNotPresent -f $output.ComputerName
                    Log-Info $detail -Type CRITICAL

                    $params = @{
                        Name               = 'AzStackHci_Upgrade_Test_NetworkATCManagementIntent_Present'
                        Title              = 'Test NetworkATC management intent is present on the node'
                        DisplayName        = 'Test NetworkATC management intent is present on the node'
                        Severity           = 'CRITICAL'
                        Description        = 'Checking NetworkATC management intent is present on the node'
                        Tags               = @{}
                        Remediation        = 'Make sure NetworkATC management intent is properly configured on the node.'
                        TargetResourceID   = 'NetworkAtcManagementIntent'
                        TargetResourceName = 'NetworkAtcManagementIntent'
                        TargetResourceType = 'NetworkAtcManagementIntent'
                        Timestamp          = [datetime]::UtcNow
                        Status             = $status
                        AdditionalData     = @{
                            Source    = $output.ComputerName
                            Resource  = 'Network ATC'
                            Detail    = $detail
                            Status    = $status
                            TimeStamp = [datetime]::UtcNow
                        }
                        HealthCheckSource  = $ENV:EnvChkrId
                    }
                    $instanceResults += New-AzStackHciResultObject @params
                }
                elseif (-not $isStorageIntentPresent -and $clusterNodesCount -gt 1) {
                    $status = 'FAILURE'
                    $detail = $luTxt.NetworkAtcStorageIntentNotPresent -f $output.ComputerName
                    Log-Info $detail -Type CRITICAL

                    $params = @{
                        Name               = 'AzStackHci_Upgrade_Test_NetworkATCStorageIntent_Present'
                        Title              = 'Test NetworkATC storage intent is present on the node'
                        DisplayName        = 'Test NetworkATC storage intent is present on the node'
                        Severity           = 'CRITICAL'
                        Description        = 'Checking NetworkATC storage intent is present on the node'
                        Tags               = @{}
                        Remediation        = 'Make sure NetworkATC storage intent is properly configured on the node if it is multi-node HCI system.'
                        TargetResourceID   = 'NetworkAtcStorageIntent'
                        TargetResourceName = 'NetworkAtcStorageIntent'
                        TargetResourceType = 'NetworkAtcStorageIntent'
                        Timestamp          = [datetime]::UtcNow
                        Status             = $status
                        AdditionalData     = @{
                            Source    = $output.ComputerName
                            Resource  = 'Network ATC'
                            Detail    = $detail
                            Status    = $status
                            TimeStamp = [datetime]::UtcNow
                        }
                        HealthCheckSource  = $ENV:EnvChkrId
                    }
                    $instanceResults += New-AzStackHciResultObject @params
                }
                else
                {
                    $status = 'SUCCESS'
                    $detail = $luTxt.NetworkAtcRequiredIntentsArePresent -f $output.ComputerName
                    Log-Info $detail

                    $params = @{
                        Name               = 'AzStackHci_Upgrade_Test_NetworkATCRequiredIntents_Present'
                        Title              = 'Test NetworkATC required intents are present on the node'
                        DisplayName        = 'Test NetworkATC required intents are present on the node'
                        Severity           = 'CRITICAL'
                        Description        = 'Checking NetworkATC required intents are present on the node'
                        Tags               = @{}
                        Remediation        = 'https://aka.ms/UpgradeNetworkATC'
                        TargetResourceID   = 'NetworkAtcIntents'
                        TargetResourceName = 'NetworkAtcIntents'
                        TargetResourceType = 'NetworkAtcIntents'
                        Timestamp          = [datetime]::UtcNow
                        Status             = $status
                        AdditionalData     = @{
                            Source    = $output.ComputerName
                            Resource  = 'Network ATC'
                            Detail    = $detail
                            Status    = $status
                            TimeStamp = [datetime]::UtcNow
                        }
                        HealthCheckSource  = $ENV:EnvChkrId
                    }
                    $instanceResults += New-AzStackHciResultObject @params
                }
            }
        }

        # check if the intents on the nodes are in healthy state
        $remoteOutput = @()
        $sb = {
            $intentStatus = Get-NetIntentStatus -ErrorAction SilentlyContinue
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                result = $intentStatus
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }

        foreach ($output in $remoteOutput)
        {
            $resultString = $output.result | Out-String
            log-info "Get-NetIntentStatus returned from node $($output.ComputerName) : $resultString"

            $failedIntents = $output.result | Where-Object { $_.ConfigurationStatus -ne 'Success' -or $_.ProvisioningStatus -ne 'Completed' }

            if ($null -ne $failedIntents)
            {
                $status = 'FAILURE'
                $detail = $luTxt.NetworkAtcIntentsStatusNotHealthy -f $output.ComputerName
                Log-Info $detail -Type CRITICAL

                $params = @{
                    Name               = "AzStackHci_Upgrade_Test_NetworkATCIntent_HealthyState"
                    Title              = "Test NetworkAtc intent configuration and provisioning status"
                    DisplayName        = "Test NetworkAtc intent configuration and provisioning status"
                    Severity           = 'CRITICAL'
                    Description        = "Checking Test NetworkAtc intent configuration and provisioning status"
                    Tags               = @{}
                    Remediation        = "Use Get-NetIntentStatus cmdlet to check the status of the intent and take necessary action to fix the issue."
                    TargetResourceID   = "NetworkAtcIntents"
                    TargetResourceName = "NetworkAtcIntents"
                    TargetResourceType = "NetworkAtcIntents"
                    Timestamp          = [datetime]::UtcNow
                    Status             = $status
                    AdditionalData     = @{
                        Source    = $output.ComputerName
                        Resource  = "NetworkAtcIntents"
                        Detail    = $detail
                        Status    = $status
                        TimeStamp = [datetime]::UtcNow
                    }
                    HealthCheckSource  = $ENV:EnvChkrId
                }
                $instanceResults += New-AzStackHciResultObject @params
            }
            elseif ($null -eq $output.result)
            {
                $status = 'FAILURE'
                $detail = $luTxt.NetworkAtcIntentsStatusNull -f $output.ComputerName
                Log-Info $detail -Type CRITICAL

                $params = @{
                    Name               = "AzStackHci_Upgrade_Test_NetworkATCIntent_StatusNull"
                    Title              = "Test NetworkAtc intent configuration and provisioning status"
                    DisplayName        = "Test NetworkAtc intent configuration and provisioning status"
                    Severity           = 'CRITICAL'
                    Description        = "Checking Test NetworkAtc intent configuration and provisioning status"
                    Tags               = @{}
                    Remediation        = "Use Get-NetIntentStatus cmdlet to check the status of the intents and take necessary action to fix the issue."
                    TargetResourceID   = "NetworkAtcIntents"
                    TargetResourceName = "NetworkAtcIntents"
                    TargetResourceType = "NetworkAtcIntents"
                    Timestamp          = [datetime]::UtcNow
                    Status             = $status
                    AdditionalData     = @{
                        Source    = $output.ComputerName
                        Resource  = "NetworkAtcIntents"
                        Detail    = $detail
                        Status    = $status
                        TimeStamp = [datetime]::UtcNow
                    }
                    HealthCheckSource  = $ENV:EnvChkrId
                }
                $instanceResults += New-AzStackHciResultObject @params
            }
            else
            {
                $status = 'SUCCESS'
                $detail = $luTxt.NetworkAtcIntentsHealthy -f $output.ComputerName
                Log-Info $detail

                $params = @{
                    Name               = "AzStackHci_Upgrade_Test_NetworkATCIntent_HealthyState"
                    Title              = "Test NetworkAtc intent configuration and provisioning status"
                    DisplayName        = "Test NetworkAtc intent configuration and provisioning status"
                    Severity           = 'CRITICAL'
                    Description        = "Checking Test NetworkAtc intent configuration and provisioning status"
                    Tags               = @{}
                    Remediation        = 'https://aka.ms/UpgradeNetworkATC'
                    TargetResourceID   = "NetworkAtcIntents"
                    TargetResourceName = "NetworkAtcIntents"
                    TargetResourceType = "NetworkAtcIntents"
                    Timestamp          = [datetime]::UtcNow
                    Status             = $status
                    AdditionalData     = @{
                        Source    = $output.ComputerName
                        Resource  = "NetworkAtcIntents"
                        Detail    = $detail
                        Status    = $status
                        TimeStamp = [datetime]::UtcNow
                    }
                    HealthCheckSource  = $ENV:EnvChkrId
                }
                $instanceResults += New-AzStackHciResultObject @params
            }
        }

        return $instanceResults
    }
    catch
    {
        throw $_
    }

}

function Test-TPMHealth
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try {
        $results = @()
        $results += Test-TpmVersion -PsSession $PsSession
        $results += Test-TpmProperties -PsSession $PsSession
        $results += Test-TpmCertificates -PsSession $PsSession
        $results | % {
            $_.Name = $_.Name -replace 'Hardware','Upgrade'
            $_.Severity = 'WARNING'
        }
        return $results
    }
    catch {
        throw $_
    }
}

function Test-BitlockerSuspension
{
    <#
    .SYNOPSIS
        Test if bitlocker is enabled but not in suspended state.
    .DESCRIPTION
        Test if bitlocker is enabled but not in suspended state.
    .EXAMPLE
        PS C:\> function Test-BitlockerSuspension
        Test if bitlocker is enabled but not in suspended state for all volumes.
    .EXAMPLE
        PS C:\> $Credential = Get-Credential -Message "Credential for $RemoteSystem"
        PS C:\> $RemoteSystemSession = New-PSSession -Computer
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )

    $remoteOutput = @()
    try {

        $sb = {

            try {
                $volumes = $null

                try {
                    $volumes = Get-BitLockerVolume
                }
                catch {
                    # Return test result as True/Pass because we dont want to fail test if bitlocker feature is not available.
                    return New-Object PSObject -Property @{
                        ComputerName = $ENV:COMPUTERNAME
                        Details = "Could not fetch bitlocker volumes. Error: " + $_.Exception.Message
                        error = $_.Exception.Message
                        result = $true
                        isBitlockerFeatureInstalled = $false
                    }
                }

                $volumeDetails = ""
                $overallStatus = $true

                if($volumes)
                {
                    $criticalVolumes = $volumes |? {$_.KeyProtector.KeyProtectorType -contains "Tpm"}
                    foreach ($volume in $criticalVolumes) {
                        # Get volume information
                        $volumeInfo = Get-BitLockerVolume -MountPoint $volume.MountPoint
                        $volumeMountPoint = $volumeInfo.MountPoint
                        $volumeProtectionStatus = $volumeInfo.ProtectionStatus
                        $volumeType = $volumeInfo.VolumeType

                        # Check if BitLocker protection is enabled
                        if($volumeInfo.ProtectionStatus -eq "On")
                        {
                            $overallStatus = $false
                        }

                        $volumeDetails += "Volume with mount point: $volumeMountPoint and type : $volumeType has a protection status of $volumeProtectionStatus. `n"
                    }
                }
                else {
                    $volumeDetails = "No bitlocker volumes found."
                }
                return New-Object PSObject -Property @{
                    ComputerName = $ENV:COMPUTERNAME
                    Details = $volumeDetails
                    result = $overallStatus
                }
            }
            catch {
                return New-Object PSObject -Property @{
                    ComputerName = $ENV:COMPUTERNAME
                    Details = $volumeDetails + $_.Exception.Message
                    error = $_.Exception.Message
                    result = $false
                }
            }
        }

        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }

        $instanceResults = @()
        foreach ($output in $remoteOutput)
        {
            Log-Info $output.Details

            if ($output.result -eq $true)
            {
                if(($output.isBitlockerFeatureInstalled -ne $null) -and ($output.isBitlockerFeatureInstalled -eq $false))
                {
                    $status = 'SUCCESS'
                    $detail = $luTxt.BitlockerFeatureNotInstalled -f $output.ComputerName
                    Log-Info $detail -Type CRITICAL
                }
                else
                {
                    $status = 'SUCCESS'
                    $detail = $luTxt.BitlockerEncryptedVolumesSuspended -f $output.ComputerName
                    Log-Info $detail
                }
            }
            else
            {
                $status = 'FAILURE'
                $detail = $luTxt.BitlockerEncryptedVolumesNotSuspended -f $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }

            $params = @{
                Name               = 'AzStackHci_Upgrade_BitlockerSuspension'
                Title              = 'Test Bitlocker Suspension'
                DisplayName        = 'Test Bitlocker Suspension'
                Severity           = 'CRITICAL'
                Description        = 'Checking if any volumes have bitlocker suspended.'
                Tags               = @{}
                Remediation        = 'https://aka.ms/UpgradeRequirements'
                TargetResourceID   = $output.ComputerName
                TargetResourceName = $output.ComputerName
                TargetResourceType = 'Security'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'Bitlocker Suspension'
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }
        return $instanceResults
    }
    catch {
        throw $_
    }
}

function Test-WdacEnablement
{
    <#
    .SYNOPSIS
        Test if WDAC is enabled
    .DESCRIPTION
        Test if WDAC is enabled
    .EXAMPLE
        PS C:\> function Test-WdacEnablement
        Test if WDAC is enabled on localhost.
    .EXAMPLE
        PS C:\> $Credential = Get-Credential -Message "Credential for $RemoteSystem"
        PS C:\> $RemoteSystemSession = New-PSSession -Computer
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try
    {
        $remoteOutput = @()
        $sb = {
            $cipFiles = Get-ChildItem -Path "$env:SystemRoot\System32\CodeIntegrity\CiPolicies\Active" -Filter *.cip
            if ($cipFiles.Count -gt 0)
            {
                # Refresh the current policy and check if audit mode is enabled from the lastest event
                Invoke-CimMethod -Namespace 'root\Microsoft\Windows\CI' -ClassName 'PS_UpdateAndCompareCIPolicy' -MethodName 'Update' -Arguments @{FilePath = $cipFiles[0].FullName} | Out-Null
                $events = Get-WinEvent -LogName "Microsoft-Windows-CodeIntegrity/Operational" -ErrorAction SilentlyContinue
                $targetEvent = $events | Where-Object { ($_.Id -in @('3099','3096')) -and ($_.Message -imatch $cipFiles[0].BaseName) } | Sort-Object TimeCreated -Descending | Select-Object -First 1
                $eventXml = [XML]$targetEvent.ToXml()
                $eventData = $eventXml.Event.EventData.Data
                $policyOptions = [System.Convert]::ToInt64($eventData[6].'#text', 16)
                # SYSTEM_INTEGRITY_POLICY_ENABLE_AUDIT_MODE 1 << 16 => 65536
                $policyResult = (($policyOptions -band 65536) -eq 0)
            }
            else
            {
                # No WDAC policy file found
                $policyResult = $false
            }
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                result = $policyResult
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }
        $instanceResults = @()
        foreach ($output in $remoteOutput)
        {
            if ($output.result)
            {
                $status = 'FAILURE'
                $detail = $luTxt.WdacEnabled -f $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }
            else
            {
                $status = 'SUCCESS'
                $detail = $luTxt.WdacNotEnabled -f $output.ComputerName
                Log-Info $detail
            }
            $params = @{
                Name               = 'AzStackHci_Upgrade_WDACEnablement'
                Title              = 'Test WDAC Enablement'
                DisplayName        = 'Test WDAC Enablement'
                Severity           = 'CRITICAL'
                Description        = 'Checking if WDAC is enabled'
                Tags               = @{}
                Remediation        = 'https://aka.ms/UpgradeRequirements'
                TargetResourceID   = $output.ComputerName
                TargetResourceName = $output.ComputerName
                TargetResourceType = 'Security'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'WDAC Enablement'
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }
        return $instanceResults
    }
    catch
    {
        throw $_
    }
}

function Test-AzureSupportedCloudType
{
     <#
    .SYNOPSIS
        Test if cluster is connected to Azure Public Cloud.
    .DESCRIPTION
        Upgrade is only supported for clusters connected to Azure Public Cloud.
    .EXAMPLE
        PS C:\> function Test-AzureSupportedCloudType
    .EXAMPLE
 
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )


    $sb= {
            try
                {
                    if(Test-Path -Path "C:\Program Files\AzureConnectedMachineAgent\azcmagent.exe")
                    {
                        $overallStatus = $true
                        $testDetails = ""
                        $arcAgentStatus = Invoke-Expression -Command "& 'C:\Program Files\AzureConnectedMachineAgent\azcmagent.exe' show -j"
                        # Parsing the status received from Arc agent
                        $arcAgentStatusParsed = $arcAgentStatus | ConvertFrom-Json

                        # Throw an error if the node is Arc enabled to any other cloud apart from Azure Public cloud.
                        # Other supported values which are not supported for Upgrade : AzureUSGovernment , AzureChinaCloud
                        if ([string]::IsNullOrEmpty($arcAgentStatusParsed.cloud))
                        {
                            $overallStatus = $false
                            $testDetails = "Unable to determine Azure cloud type. ARC Agent status read: [{0}]" -f $arcAgentStatus
                        }
                        elseif (($arcAgentStatusParsed.cloud -ne "AzureCloud"))
                        {
                            $overallStatus = $false
                            $testDetails = "{0}: Arc Agent is connected to {1}: cloud, which is not supported for upgrade." -f  $ENV:COMPUTERNAME,$arcAgentStatusParsed.cloud
                        }
                    }
                    else
                    {
                        $overallStatus = $false
                        $testDetails ="ARC agent installation cannot be found at : C:\Program Files\AzureConnectedMachineAgent\azcmagent.exe"
                    }
                    return New-Object PSObject -Property @{
                        ComputerName = $ENV:COMPUTERNAME
                        Details = $testDetails
                        result = $overallStatus
                        }
                }
                catch
                {
                    return New-Object PSObject -Property @{
                        ComputerName = $ENV:COMPUTERNAME
                        Details = $_.Exception.Message
                        result = $false
                    }
                }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }

        $instanceResults = @()
        foreach ($output in $remoteOutput)
        {
            Log-Info $output.Details
            if ($output.result)
            {
                $status = 'SUCCESS'
                $detail = $luTxt.CloudSupported -f $output.ComputerName
                Log-Info $detail
            }
            else
            {
                $status = 'FAILURE'
                $detail = $luTxt.CloudNotSupported -f $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }

            $params = @{
                Name               = 'AzStackHci_Upgrade_SupportedCloud'
                Title              = 'Test Supported Cloud Type'
                DisplayName        = 'Test Supported Cloud Type'
                Severity           = 'CRITICAL'
                Description        = 'Checking if any node is connected to an unsupported cloud'
                Tags               = @{}
                Remediation        = 'https://learn.microsoft.com/en-us/azure-stack/hci/concepts/system-requirements-23h2'
                TargetResourceID   = $output.ComputerName
                TargetResourceName = $output.ComputerName
                TargetResourceType = 'Feature'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'Azure Cloud'
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }
        return $instanceResults


}

function Test-AksHciInstallState
{
    <#
    .SYNOPSIS
        Test Windows Deduplication is enabled
    .DESCRIPTION
        Test Windows Deduplication is enabled
    .EXAMPLE
        PS C:\> Test-WindowsDeduplication
        Test if Windows Deduplication is enabled on localhost.
    .EXAMPLE
        PS C:\> $Credential = Get-Credential -Message "Credential for $RemoteSystem"
        PS C:\> $RemoteSystemSession = New-PSSession -Computer
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try
    {
        $remoteOutput = @()
        $sb = {
            Import-Module AksHci -ErrorAction SilentlyContinue
            $result = [bool](Get-Module AksHci)
            if($result)
            {
                try
                {
                    $installState = (Get-AksHciConfig).AksHci.installState -ne "NotInstalled"
                    if($installState) {
                        return New-Object PSObject -Property @{
                            ComputerName = $ENV:COMPUTERNAME
                            result = $false
                            error = "AksHci is installed"
                        }
                    }
                }
                catch
                {
                    #NOOP
                }
            }
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                result = $true
                error = ""
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }
        $instanceResults = @()
        foreach ($output in $remoteOutput)
        {
            if ($output.result)
            {
                $status = 'SUCCESS'
                $detail = $luTxt.AksHciNotInstalled -f $output.ComputerName
                Log-Info $detail
            }
            else
            {
                $status = 'FAILURE'
                $detail = $luTxt.AksHciInstalled -f $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }
            $params = @{
                Name               = 'AzStackHci_Upgrade_AksHci'
                Title              = 'Test AKS HCI install state'
                DisplayName        = "Test AKS HCI install state on $($output.ComputerName)"
                Severity           = 'CRITICAL'
                Description        = 'Checking if AKS HCI is installed'
                Tags               = @{}
                Remediation        = 'https://aka.ms/UpgradeRequirements'
                TargetResourceID   = $output.ComputerName
                TargetResourceName = $output.ComputerName
                TargetResourceType = 'Feature'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'AKS HCI'
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }
        return $instanceResults
    }
    catch
    {
        throw $_
    }
}

function Test-MocInstallState
{
    <#
    .SYNOPSIS
        Test Windows Deduplication is enabled
    .DESCRIPTION
        Test Windows Deduplication is enabled
    .EXAMPLE
        PS C:\> Test-WindowsDeduplication
        Test if Windows Deduplication is enabled on localhost.
    .EXAMPLE
        PS C:\> $Credential = Get-Credential -Message "Credential for $RemoteSystem"
        PS C:\> $RemoteSystemSession = New-PSSession -Computer
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try
    {
        $remoteOutput = @()
        $sb = {
            Import-Module Moc -ErrorAction SilentlyContinue
            $result = [bool](Get-Module Moc)
            if($result)
            {
                try
                {
                    $installState = (Get-MocConfig).installState -ne "NotInstalled"
                    if($installState) {
                        return New-Object PSObject -Property @{
                            ComputerName = $ENV:COMPUTERNAME
                            result = $false
                            error = "Moc is installed"
                        }
                    }
                }
                catch
                {
                    #NOOP
                }
            }
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                result = $true
                error = ""
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }
        $instanceResults = @()
        foreach ($output in $remoteOutput)
        {
            if ($output.result)
            {
                $status = 'SUCCESS'
                $detail = $luTxt.MocNotInstalled -f $output.ComputerName
                Log-Info $detail
            }
            else
            {
                $status = 'FAILURE'
                $detail = $luTxt.MocInstalled -f $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }
            $params = @{
                Name               = 'AzStackHci_Upgrade_Moc'
                Title              = 'Test MOC install state'
                DisplayName        = "Test MOC install state on $($output.ComputerName)"
                Severity           = 'CRITICAL'
                Description        = 'Checking if MOC is installed'
                Tags               = @{}
                Remediation        = 'https://aka.ms/UpgradeRequirements'
                TargetResourceID   = $output.ComputerName
                TargetResourceName = $output.ComputerName
                TargetResourceType = 'Feature'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'MOC'
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }
        return $instanceResults
    }
    catch
    {
        throw $_
    }
}

function Test-MocServicesInstallState
{
    <#
    .SYNOPSIS
        Test Windows Deduplication is enabled
    .DESCRIPTION
        Test Windows Deduplication is enabled
    .EXAMPLE
        PS C:\> Test-WindowsDeduplication
        Test if Windows Deduplication is enabled on localhost.
    .EXAMPLE
        PS C:\> $Credential = Get-Credential -Message "Credential for $RemoteSystem"
        PS C:\> $RemoteSystemSession = New-PSSession -Computer
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try
    {
        $remoteOutput = @()
        $sb = {
            $service = Get-Service -Name wssdcloudagent -ErrorAction SilentlyContinue
            if($null -ne $service)
            {
                return New-Object PSObject -Property @{
                    ComputerName = $ENV:COMPUTERNAME
                    result = $false
                    error = "wssdcloudagent service is running"
                }
            }
            $service = Get-Service -Name wssdagent -ErrorAction SilentlyContinue
            if($null -ne $service)
            {
                return New-Object PSObject -Property @{
                    ComputerName = $ENV:COMPUTERNAME
                    result = $false
                    error = "wssdagent service is running"
                }
            }
            $service = Get-Service -Name MocHostAgent -ErrorAction SilentlyContinue
            if($null -ne $service)
            {
                return New-Object PSObject -Property @{
                    ComputerName = $ENV:COMPUTERNAME
                    result = $false
                    error = "MocHostAgent service is running"
                }
            }
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                result = $true
                error = ""
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }
        $instanceResults = @()
        foreach ($output in $remoteOutput)
        {
            if ($output.result)
            {
                $status = 'SUCCESS'
                $detail = $luTxt.MocServicesNotInstalled -f $output.ComputerName
                Log-Info $detail
            }
            else
            {
                $status = 'FAILURE'
                $detail = $luTxt.MocServicesInstalled -f $output.ComputerName
                Log-Info $detail -Type CRITICAL
            }
            $params = @{
                Name               = 'AzStackHci_Upgrade_MocServices'
                Title              = 'Test MOC services running'
                DisplayName        = "Test MOC services running on $($output.ComputerName)"
                Severity           = 'CRITICAL'
                Description        = 'Checking MOC services running state'
                Tags               = @{}
                Remediation        = 'https://aka.ms/UpgradeRequirements'
                TargetResourceID   = $output.ComputerName
                TargetResourceName = $output.ComputerName
                TargetResourceType = 'Feature'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = 'MOC services'
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }
        return $instanceResults
    }
    catch
    {
        throw $_
    }
}

function Test-Language
{
    <#
    .SYNOPSIS
        Test if the language is English-US
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [System.Management.Automation.Runspaces.PSSession[]]
        $PsSession
    )
    try
    {
        $remoteOutput = @()
        $sb = {
            $lang = Get-WinUserLanguageList
            return New-Object PSObject -Property @{
                ComputerName = $ENV:COMPUTERNAME
                Language = $lang
            }
        }
        if ($PsSession)
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb -Session $PsSession
        }
        else
        {
            $remoteOutput += Invoke-Command -ScriptBlock $sb
        }
        $instanceResults = @()
        foreach ($output in $remoteOutput)
        {
            Log-Info "Langauges on $($output.ComputerName) :"
            Log-Info  ($output.Language | Out-String)
            if ($output.Language.LanguageTag -like 'en-*')
            {
                $status = 'SUCCESS'
                $detail = $luTxt.LanguageEnglishUS -f $output.ComputerName
                Log-Info $detail
            }
            else
            {
                $status = 'FAILURE'
                $detail = $luTxt.LanguageNotEnglishUS -f $output.ComputerName, $output.Language.LanguageTag
                Log-Info $detail -Type CRITICAL
            }
            $params = @{
                Name               = 'AzStackHci_Upgrade_Language'
                Title              = 'Test Language is English'
                DisplayName        = 'Test Language is English'
                Severity           = 'CRITICAL'
                Description        = 'Checking if the language is English'
                Tags               = @{}
                Remediation        = "https://aka.ms/UpgradeRequirements"
                TargetResourceID   = $output.ComputerName
                TargetResourceName = $output.ComputerName
                TargetResourceType = 'Language'
                Timestamp          = [datetime]::UtcNow
                Status             = $status
                AdditionalData     = @{
                    Source    = $output.ComputerName
                    Resource  = "Language: $($output.Language.LanguageTag)"
                    Detail    = $detail
                    Status    = $status
                    TimeStamp = [datetime]::UtcNow
                }
                HealthCheckSource  = $ENV:EnvChkrId
            }
            $instanceResults += New-AzStackHciResultObject @params
        }
        return $instanceResults
    }
    catch
    {
        throw $_
    }
}

function Test-Storage
{
    [CmdletBinding()]
    param ()
    try {
        $results = @()
        $poolConfigXml = [xml]'<StoragePool><Volumes><Volume Name="Infrastructure_1" Size="256GB" MinNodeCount="1" ></Volume></Volumes></StoragePool>'
        $results += Invoke-AzStackHciStorageValidation -PoolConfigXml $poolConfigXml -PassThru
        $results | % {
            $_.Name = $_.Name -replace 'AzStackHci_Storage','AzStackHci_Upgrade'
        }
        return $results
    }
    catch {
        throw $_
    }
}

Export-ModuleMember -Function Test-*
# SIG # Begin signature block
# MIIoKgYJKoZIhvcNAQcCoIIoGzCCKBcCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBpIiIROue6VCIw
# GzyxCJuNnZKmRkxGjTmLP2eHENPXa6CCDXYwggX0MIID3KADAgECAhMzAAADrzBA
# DkyjTQVBAAAAAAOvMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWN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