Private/Export-HtmlFunctions.ps1

function Export-HtmlContent {
    <#
    .SYNOPSIS
    Exports the complete Windows Virtual Desktop environment, based on the hostpool name.
    .DESCRIPTION
    The function will help you exporting the complete WVD environment to common output types as HTML and CSV.
    .PARAMETER HostpoolName
    Enter the WVD hostpoolname name.
    .PARAMETER ResourceGroupName
    Enter the WVD hostpool resource group name.
    .PARAMETER
    .EXAMPLE
    Export-WvdConfig -Hostpoolname $hostpoolName -resourceGroup $ResourceGroup -Scope Hostpool,SessionHosts -Verbose -FilePath .\wvdexport.html
    Add a comment to existing incidnet
    #>

    [CmdletBinding()]
    param (
        [parameter(Mandatory, ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [object]$Content,

        [parameter(ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [object]$Properties,

        [parameter(Mandatory, ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [string]$FilePath,

        [parameter()]
        [ValidateNotNullOrEmpty()]
        [Switch]$FormatAlerts,

        [parameter(Mandatory, ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [object]$Scope

    )
    Begin {
        $HtmlBody = [System.Collections.Generic.List[string]]::new()
    }
    Process {
        $ConvertParameters = @{
            PreContent = "<p>WVD information for $Scope</p>"
            Fragment   = $true
        }
        $HtmlBody.Add(($Content | ConvertTo-Html @ConvertParameters -Property $Properties))
    }
    End {
        $Css = Get-Content -Path '.\Private\exportconfig.css' -Raw
        $style = ("<style>`n") + $Css + ("`n</style>")
        if ($FormatAlerts){
            $HtmlBody -replace '<td>0</td>', '<td class="WrongStatus">False</td>'
        }
        $HtmlParameters = @{
            Title       = "WVD Information Report"
            body        = $HtmlBody
            Head        = $style
            PostContent = "<H5><i>$(get-date)</i></H5>"
        }
        Write-Verbose "Exporting config to $FilePath"
        ConvertTo-HTML @HtmlParameters | Out-File $FilePath
    }
}

function Get-HostpoolHtmlContent {
    <#
    .SYNOPSIS
    Exports the complete Windows Virtual Desktop environment, based on the hostpool name.
    .DESCRIPTION
    The function will help you exporting the complete WVD environment to common output types as HTML and CSV.
    .PARAMETER HostpoolName
    Enter the WVD hostpoolname name.
    .PARAMETER ResourceGroupName
    Enter the WVD hostpool resource group name.
    .PARAMETER
    .EXAMPLE
    Export-WvdConfig -Hostpoolname $hostpoolName -resourceGroup $ResourceGroup -Scope Hostpool,SessionHosts -Verbose -FilePath .\wvdexport.html
    Add a comment to existing incidnet
    #>

    [CmdletBinding()]
    param (
        [parameter(Mandatory, ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [string]$HostpoolName,

        [parameter(Mandatory, ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [string]$ResourceGroupName
    )
    $ConvertParameters = @{
        PreContent = "<p>Hostpool information for $HostpoolName</p>"
        Property   = "Name", "Description", "HostpoolType", "Type", "Location", "RegistrationInfoExpirationTime", "StartVMOnConnect", "ValidationEnvironment"
        Fragment   = $true
    }
    $Parameters = @{
        HostPoolName      = $HostpoolName 
        ResourceGroupName = $ResourceGroupName 
    }
    $HostpoolContent = Get-AzWvdHostPool @Parameters | ConvertTo-Html @ConvertParameters
    return $HostpoolContent
}
function Get-SessionHostHtmlContent {
    <#
    .SYNOPSIS
    Exports the complete Windows Virtual Desktop environment, based on the hostpool name.
    .DESCRIPTION
    The function will help you exporting the complete WVD environment to common output types as HTML and CSV.
    .PARAMETER HostpoolName
    Enter the WVD hostpoolname name.
    .PARAMETER ResourceGroupName
    Enter the WVD hostpool resource group name.
    .PARAMETER
    .EXAMPLE
    Export-WvdConfig -Hostpoolname $hostpoolName -resourceGroup $ResourceGroup -Scope Hostpool,SessionHosts -Verbose -FilePath .\wvdexport.html
    Add a comment to existing incidnet
    #>

    [CmdletBinding()]
    param (
        [parameter(Mandatory, ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [string]$HostpoolName,

        [parameter(Mandatory, ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [string]$ResourceGroupName
    )
    $ConvertParameters = @{
        PreContent = "<p>Sessionhosts in $HostpoolName</p>"
        Property   = "vmLatestVersion", "vmName", "resourceGroup", "LastVersion", "currentImageVersion", "imageName", "imageGallery", "subscriptionId"
        Fragment   = $true
    }
    $Parameters = @{
        HostPoolName      = $HostpoolName 
        ResourceGroupName = $ResourceGroupName 
    }
    $SessionHostContent = Get-WvdImageVersionStatus @Parameters | ConvertTo-Html @ConvertParameters
    $SessionHostContent = $SessionHostContent -replace '<td>1</td>', '<td class="GoodStatus">True</td>'
    $SessionHostContent = $SessionHostContent -replace '<td>0</td>', '<td class="WrongStatus">False</td>'
    return $SessionHostContent
}

function Get-SubnetConfigHtmlContent {
    <#
    .SYNOPSIS
    Exports the complete Windows Virtual Desktop environment, based on the hostpool name.
    .DESCRIPTION
    The function will help you exporting the complete WVD environment to common output types as HTML and CSV.
    .PARAMETER HostpoolName
    Enter the WVD hostpoolname name.
    .PARAMETER ResourceGroupName
    Enter the WVD hostpool resource group name.
    .PARAMETER
    .EXAMPLE
    Export-WvdConfig -Hostpoolname $hostpoolName -resourceGroup $ResourceGroup -Scope Hostpool,SessionHosts -Verbose -FilePath .\wvdexport.html
    Add a comment to existing incidnet
    #>

    [CmdletBinding()]
    param (
        [parameter(Mandatory, ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [string]$HostpoolName,

        [parameter(Mandatory, ParameterSetName = 'Parameters')]
        [ValidateNotNullOrEmpty()]
        [string]$ResourceGroupName
    )
    $ConvertParameters = @{
        Property   = "Name", "PrivateEndpointNetworkPolicies", "PrivateLinkServiceNetworkPolicies", "NatGateway"
        Fragment   = $true
        PreContent = "<p>SubnetConfig in $HostpoolName</p>"
    }
    $Parameters = @{
        HostPoolName      = $HostpoolName 
        ResourceGroupName = $ResourceGroupName 
    }
    $SubnetConfigContent = Get-WvdSubnet @Parameters |  ConvertTo-Html @ConvertParameters
    return $SubnetConfigContent
}