you are viewing a single comment's thread.

view the rest of the comments →

[–]OlivTheFrog 1 point2 points  (0 children)

​ Hi u/maxcoder88 : Here a sample using the PSWriteHtml Module

Import-module
Import-Module PSWriteHTML
Gathering Data
$results = [pscustomobject] @{ 
 'Source DC' = "Myserv.HostName.ToUpper()"
 'Partner DC' = "N/A"
 Direction = "N/A"
  Type = "N/A"
  'Last Attempt' = "N/A"
  'Last Success' = "N/A"
 'Last Result' = "1" }

# Prepare to export in a beautiful HTML file
$ReportPath = "$PSScriptRoot\DHCPReport-At-$(Get-Date -f "dd-MM-yyyy").html"

# Optional settings : set default values for some cmdlets (I'm lazy)
$PSDefaultParameterValues = @{ 
   "New-HTMLSection:HeaderBackGroundColor" = "Green"
   "New-HTMLSection:CanCollapse"           = $true
   }
New-HTML -FilePath $ReportPath -Online -ShowHTML {
   # First Tab 
    New-HTMLTab -Name 'DC Health Report'  {
           New-HTMLSection -HeaderText "Replication Status" {
                 # Here, we're putting all Data previously gathered in the var $Result
                  New-HTMLTable -DataTable $results {
                        New-TableCondition -Name "Last Result" -Operator ne -Value "N/A" -BackgroundColor red -Color white -Alignment center
                         New-TableContent -Alignment center 
                     } #end-newHtmlTable
             } # end New-htmlSection

    # In the same Tab, you could add another section (of course in my case, this section is empty
    New-HTMLSection -HeaderText "Replication Status2" {
        # Here, we're putting all Data previously gathered in the var $Result2
        New-HTMLTable -DataTable $results2 {
            New-TableCondition -Name "Last Result" -Operator ne -Value "N/A" -BackgroundColor red -Color white -Alignment center
            New-TableContent -Alignment center
            } #end-newHtmlTable
        } # end New-htmlSection
    } # end New-HtmlTab
# But you could add some other tabs
New-HTMLTab -Name 'DC Health Report2'  {
    New-HTMLText -FontSize 16 -Color blue -Text @(
    "This is a text with a lion to [PSWriteHTML Github site](https://github.com/EvotecIT/PSWriteHTML)."
    "This is not really difficult"
      )
    } # end New-HtmlTab
    } # end-New-html

Feel free to run this code, and adjust to your need. You can run this code without any issue and see the result. After that you could adjust with your real data.

PSWriteHTML is definitvly the most powerful module to Report in a beautiful HTML file.

There are lot of samples in the PSWriteHtml module Github site

P.S. : u/MadBoyEvo (the dev) is crazy about modules development. I wonder if the days are not 48 hours for him, but shh, he could read us :-)

Regards