Public/Export-WvdConfig.ps1

function Export-WvdConfig {
    <#
    .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(DefaultParameterSetName='Hostpool')]
    param (
        [parameter(Mandatory, ParameterSetName = 'Hostpool')]
        [ValidateNotNullOrEmpty()]
        [string]$HostpoolName,

        [parameter(Mandatory, ParameterSetName = 'Hostpool')]
        [ValidateNotNullOrEmpty()]
        [string]$ResourceGroupName,

        [parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'InputObject')]
        [ValidateNotNullOrEmpty()]
        [PSCustomObject]$InputObject,

        [parameter()]
        [switch]$Html,

        [parameter()]
        [switch]$CSV,

        [parameter()]
        [string]$FilePath,

        [parameter()]
        [ValidateSet("Hostpool", "Sessionhosts","SubnetConfig")]
        [array]$Scope
    )

    if ($null -eq $FilePath) {
        Write-Verbose "Filepath is null, using default .\WvdExport.Html"
        $FilePath = ".\WvdExport.Html"
    }
    $HtmlBody = [System.Collections.Generic.List[string]]::new()
    $Parameters = @{
        HostpoolName      = $HostpoolName 
        ResourceGroupName = $ResourceGroupName 
    }
    switch -wildcard ($Scope) {
        Hostpool* { 
            $HtmlBody.Add((Get-HostpoolHtmlContent @Parameters))
        }
        SessionHosts* { 
            $HtmlBody.Add((Get-SessionHostHtmlContent @Parameters))
        }
        SubnetConfig* { 
            $HtmlBody.Add((Get-SubnetConfigHtmlContent @Parameters))
        }        
        Default {
            $HtmlBody.Add((Get-SessionHostHtmlContent @Parameters))
        }
    }
    $Css = Get-Content -Path '.\Private\exportconfig.css' -Raw
    $style= ("<style>`n") + $Css + ("`n</style>")
    $HtmlParameters = @{
        Title  = "WVD Information Report for $HostpoolName"
        body   = $HtmlBody
        Head   = $style
        PostContent = "<H5><i>$(get-date)</i></H5>"
    }
    Write-Verbose "Exporting config to $FilePath"
    ConvertTo-HTML @HtmlParameters | Out-File $FilePath
}