r/PowerShell • • Apr 02 '19

Dashimo - PowerShell Generated HTML Dashboard in a single file

Something that may come useful to you guys. Recently I've written Dashimo which allows creating HTML dashboards in a very easy, intuitive way. With it, you no longer have to build an object and then play with HTML to get it to display correctly in HTML.

The whole idea with screenshots is described in my blog.

https://evotec.xyz/meet-dashimo-powershell-generated-dashboard/

Dashimo generates a single HTML file that you can attach to email or host on a website. There is no DB or anything else. Keep in mind this can't be used as Email Content because it holds JS and heavy CSS. But you can attach it to email and the features it holds within that HTML are well worth it.

On my blog, I'm explicitly showing it using my Active Directory module but you can pass anything to Table. Even $Object = Get-Process if you really want to.

Dashboard -Name 'Dashimo Test' -FilePath $PSScriptRoot\Dashboard.html {
    Tab -Name 'Forest' {
        Section -Name 'Forest Information' -Invisible {
            Section -Name 'Forest Information' {
                Table -HideFooter -DataTable $DataSetForest.ForestInformation
            }
            Section -Name 'FSMO Roles' {
                Table -HideFooter -DataTable $DataSetForest.ForestFSMO
            }
        }
   }
} 

The easiest sample looks like this.

$Process = Get-Process | Select-Object -First 30

Dashboard -Name 'Dashimo Test' -FilePath $PSScriptRoot\Dashboard1.html {
    Section -Name 'Test' {
        Table -DataTable $Process
    }
}

You can have as many sections/panels as you need. Tabs also work just fine. Charts are coming sometime soon.

130 Upvotes

90 comments sorted by

View all comments

Show parent comments

1

u/MadBoyEvo Apr 11 '19

Use dashimo

$Object = Import-Csv -Path "\\int.zero.zero\zero\zero\ICT\zero\SD\PS-Modules\logs\log_test.csv"
Dashboard -FilePath ... {
    Table -DataTable $Object
}

Same thing

1

u/MadBoyEvo Apr 11 '19

You can also use Out-HtmlView -FilePath ... which will save the file to File but it also opens up HTML anyway

0

u/[deleted] Apr 11 '19

[deleted]

1

u/MadBoyEvo Apr 11 '19

Save path of html?

0

u/[deleted] Apr 11 '19

[deleted]

2

u/MadBoyEvo Apr 11 '19

Experiment and see

0

u/[deleted] Apr 11 '19

[deleted]

1

u/MadBoyEvo Apr 11 '19

First of all drop the out-Null. You don't need to use it if you're giving FilePath. If you don't give filepath HTML is returned. If you do, file is saved and that's it.

2nd there is no Append in Dashimo. It will overwrite your content. If you want to have more content you have to build it every time.

$HTML_LOG1 = Import-Csv "\\int.int.int\int\int\ICT\int\SD\PS-Modules\logs\log_test.csv"
$HTML_LOG2 = Import-Csv "\\int.int.int\int\int\ICT\int\SD\PS-Modules\logs\log_test.csv"

Dashimo -FilePath ... {
   Table -DataTable $HTML_LOG1
   Table -DataTable $HTML_LOG2
}

or

$HTML_LOG3 = $HTML_LOG1 + $HTML_LOG2 

Dashimo -FilePath .. {
   Table -DataTable $HTML_LOG3
}

0

u/[deleted] Apr 11 '19

[deleted]

1

u/MadBoyEvo Apr 11 '19

Right, that's not really a problem.

$UserFailed = $true
if ($UserFailed) {
    $Object = Import-CSV with old data 
} else {
    $Object = Import-Csv with old data
}

Add data to $Object (whether good or bad)
DisplayOutput from $object

Alternatively, load both Failed/Good and simply add where necessary and display. I'm not seeing a problem here.

0

u/[deleted] Apr 11 '19

[deleted]

→ More replies (0)

1

u/MadBoyEvo Apr 11 '19
Clear-Host
#Import-Module -name "\\int.zero.zero\zero\zero\ICT\zero\SD\PS-Modules\Dashimo\0.0.1\Dashimo.psm1" | execution-policy Unrestricted

$NewADVar = $true # or false...

Write-Color "`r"
Write-Color -color red "=========================================================="
Write-Color -color cyan, yellow "Username: ", "$($UserID)"
Write-Color -color yellow, cyan "Passwd: ", "Welkom01"
Write-Color -color cyan, yellow "E-mail: ", "$($AliasID)@domain.com"
Write-Color -color red "=========================================================="

$creator = (Get-ADUser $env:USERNAME).samAccountName
$24hourformat = $(get-date).ToString("dd/MM/yyyy HH:mm:ss")
$LogPath = "$Env:USERPROFILE\Desktop\Test.csv"
$HTMLPath = "$Env:USERPROFILE\Desktop\htmlfile.html"

$Update = [PSCustomObject] @{
    UserID  = $UserID
    Status  = if ($NewADVar) { 'User Added' } else { 'User Failed'}
    Creator = $creator
    Time    = $24hourformat
}

$Update | Export-Csv -LiteralPath $LogPath -Append
$HTML_LOG = Import-Csv -LiteralPath $LogPath

Dashboard -FilePath $HTMLPATH {
    Table -DataTable $HTML_LOG {
        TableConditionalFormatting -Name 'Status' -ComparisonType string -Operator eq -Value 'User Failed' -BackGroundColor Red -Row
        TableConditionalFormatting -Name 'Status' -ComparisonType string -Operator eq -Value 'User Added' -BackgroundColor Green -Row
    }
}

That's how I would have done it if I would be doing this at all. You shouldn't use .CSV extension if it's not real CSV. I've modified your code a bit, but please notice that TableConditionalFormatting is in newer versions. You seem to be downloading stuff and using it that way.

0

u/[deleted] Apr 11 '19

[deleted]

→ More replies (0)