r/PowerShell • u/MadBoyEvo • 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.
4
2
u/jollyfreek Apr 02 '19
Can the charts be sent through email? I've tried some other dashboard and html report generating tools for this, but because the charts are generated with javascript, they won't properly send via email.
3
u/MadBoyEvo Apr 02 '19
You can send HTML via email, as an attachment. That's what I do. Meaning the HTML will have to be opened up in an external, default browser (double click by receiver). Email doesn't really play well with JS/CSS on a level i'm using it.
2
u/jollyfreek Apr 02 '19
Ok. I might just have to fix my though process/workflow a bit then. The old way was to send an email to an email app to send the email to our slack instance, which would then show the report in the body of the email. the report is currently just tables with vm names and performance numbers. I wanted to update it with graphs, but haven't found a great solution for non-js graphing, and turned my attention elsewhere. I'll definitely give this a shot when my attention is back on that project!
3
2
Apr 02 '19 edited Apr 02 '19
This is awesome, changing a lot of my scripts over now, first one took about 5 minutes. Very intuitive and nicely done! Is there any way for the Section to become fullsize? The -height switch just seems to make it 0 lines, with an INT from 1 to 999
3
u/MadBoyEvo Apr 02 '19 edited Apr 02 '19
As for height, the full size of what? Of the current page? I'll take a look if it can be fixed. I've not played a lot on the height size.
When you generate height do you see it in HTML?
EDIT. I see a problem now. I'll fix it. It doesn't work as intended.
1
3
u/MadBoyEvo Apr 02 '19
Thinking about it more I think Height will be removed from Section/Panel elements because it doesn't make sense. There should be height on Table/Charts only because the idea is that size on width/height should size itself based on content inside. For example if you add 3 panels next to each other output should size the height based on highest element. Therefore I'll fix it in a way where change of size, visibility should apply to Table. Makes sense?
1
Apr 02 '19
Absoutly, basically I have a table with 40 items and i would like it to run out of the page for easy scrolling rather than paging. I know its not really a single pane of glass type but it fits my needs
3
u/MadBoyEvo Apr 02 '19
Can you test this for me?
Check your generated page HTML, edit it:
find: "paging": true, add next to it: scrollY: '90vh',
You can set paging to false. Let me know if that looks ok for you?
Alternatively:
scrollY: '90vh', scrollCollapse: true, paging: false
in place of paging true.
2
Apr 02 '19
Just changing it to false works perfectly, maybe a switch -MaxSize or -FullPage, for now i will find string and replace after Dashimo.
Great darn script!
3
u/MadBoyEvo Apr 02 '19
This is code in PSWriteHTML that I'm testing now
New-HTML -TitleText 'My title' -UseCssLinks:$true -UseJavaScriptLinks:$true -FilePath $PSScriptRoot\Example15.html { New-HTMLContent -HeaderText 'Test' { New-HTMLTable -DataTable $Process -PagingOptions @(50, 100, 150, 200) } }I think I will update Dashimo and expose PagingOptions, and other parameters that the table has.
param( [alias('ArrayOfObjects', 'Object', 'Table')][Array] $DataTable, [string[]][ValidateSet('copyHtml5', 'excelHtml5', 'csvHtml5', 'pdfHtml5')] $Buttons = @('copyHtml5', 'excelHtml5', 'csvHtml5', 'pdfHtml5'), [string[]][ValidateSet('numbers', 'simple', 'simple_numbers', 'full', 'full_numbers', 'first_last_numbers')] $PagingStyle = 'full_numbers', [int[]]$PagingOptions = @(15, 25, 50, 100), [switch]$DisablePaging, [switch]$DisableOrdering, [switch]$DisableInfo, [switch]$HideFooter, [switch]$DisableColumnReorder, [switch]$DisableProcessing, [switch]$DisableResponsiveTable, [switch]$DisableSelect, [switch]$DisableStateSave, [switch]$DisableSearch, [bool] $ScrollCollapse, [string[]][ValidateSet('display', 'cell-border', 'compact', 'hover', 'nowrap', 'order-column', 'row-border', 'stripe')] $Style = @('display', 'compact'), [switch]$Simplify, [string]$TextWhenNoData = 'No data available.', [int] $ScreenSizePercent = 0I'll release updated version tomorrow or so. Actually scrollY: '90vh' is 90% of the screen. But if you don't have enough content things look different.
2
1
2
2
u/KDRIUP Apr 03 '19 edited Apr 17 '19
This is pretty slick. I just started to dabble in it using some dbatools commands.
$cpu = Get-DbaCmsRegServer -SqlInstance myCMSserver -group test | Get-DbaCpuUsage
$io = Get-DbaCmsRegServer -SqlInstance myCMSserver -group test | Get-DbaIoLatency
$query = Get-DbaCmsRegServer -SqlInstance myCMSserver -group test | Get-DbaQueryExecutionTime
Dashboard -Name 'DB Health Dashboard' -FilePath c:\dba\ServerHealth.html {
tab -Name 'CPU Usage' {
Table -DataTable $cpu
}
tab -Name 'IO Latency' {
Table -DataTable $io
}
tab -Name 'Query Exectutions' {
Table -DataTable $query
}
}3
2
u/Lee_Dailey [grin] Apr 03 '19
howdy KDRIUP,
it looks like you used the New.Reddit.com
Inline Codebutton. it's4th5th from the lefthidden in the..."more" menu & looks like</>.on Old.Reddit.com, the above does NOT line wrap, nor does it side-scroll.
for long-ish single lines OR for multiline code, please, use the
Code Blockbutton. it's the11th12th one from the left, & is just to the left ofhidden in the..."more" menu.that will give you fully functional code formatting, from what i can tell so far. [grin]
take care,
lee
2
u/xlrod Apr 03 '19
Thanks for sharing this. Question: What is the -AutoRefresh parameter's intended use? I would like for the page to refresh and pull new data, but it just refreshed the old html document. I can work around this, just wanted to know what's the correct use.
3
u/MadBoyEvo Apr 03 '19
Well -AutoRefresh should refresh the page. If you generate new HTML in the background it should get new content. I think I tested this and it worked, but maybe I did tested wrong. This is in seconds. so Autorefresh 30 would autorefresh every 30 seconds.
2
u/xlrod Apr 03 '19
Ah yes, got it! So the
-AutoRefreshplaces the refresh inside the HTML and we need to keep a powershell running in the background to generate a new one. Thanks, this is very helpful!2
u/MadBoyEvo Apr 03 '19
Great. Keep in mind that Height will go away (since it doesn't work as expected) and new features will come in in next version.
2
Apr 03 '19
You could also schedule a task, i find it easier to identify failures then leave it running in memory.
2
2
u/motsanciens Apr 03 '19
This is pretty cool. I am playing around with it to show DHCP leases, and the search feature works really well. When I dug into the code, I saw that it has a dependency on the PSWriteHtml module, so I looked at that, and the Table function is an alias for New-HTMLTable, right? But I've tried to include some parameters from that function to display more rows per page, and I haven't gotten it to work. What's the right way to specify that?
3
u/MadBoyEvo Apr 03 '19
I'll get those parameters into Table in next release. There will be also conditional formatting which I already have in testing. If you can't wait I can show you how to fix it in PSWriteHTML. I mean Dashimo is just an intuitive wrapper around PSWriteHTML. I am still not sure how things are supposed to work in PSWriteHTML so things may change drastically from time to time and if that happens I'll simply update Dashimo. Dashimo approach shouldn't change much except for Height parameter which isn't working as I want it.
2
u/motsanciens Apr 03 '19
OK, no worries. Thought maybe I was just not finding what was already there :)
2
u/MadBoyEvo Apr 03 '19
[int[]]$PagingOptions = @(15, 25, 50, 100), [switch]$DisablePaging,Are the ones you should worry about.
-PagingOptions @(50,100,150,200)or simply-DisablePagingshoould solve it.
2
u/Andy_C33 Apr 04 '19
Hi,
I'm kinda new to PS so i'm possible missing something really simple here but i get this error
"Find-Events : The term 'Find-Events' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again."
any suggestions?
Everything else runs just fine and its great :-)
2
u/MadBoyEvo Apr 04 '19
Find-Events is part of PSWinReporting Module
Overview: https://evotec.xyz/hub/scripts/pswinreporting-powershell-module/
Last post: https://evotec.xyz/pswinreporting-1-8-split-of-branches-legacy-vs-new-hope/
Install-Module PSWinReporting -AllowPrerelease -Force
It's in preview thou (hence why you need AllowPrerelease) so there's no documentation for it at all. 2.0 is completly rewritten PSWinReporting. You don't need Find-Events for Dashimo. That was just an example, unless you want it's features...
2
u/Andy_C33 Apr 04 '19
hi,
Thank you for replying, the module installs fine (although the -allowprerelease switch is invalid)
but I still get that find-events error when running the entire script (the modules appear to import ok, IE: no errors)
I'm probably missing something really silly here... sorry for my dumbness :-)
2
Apr 04 '19
Any control over the sort? I am doing account lockouts and it sorts the time as oldest first no matter the order of my CSV. My PoSH is strong, web not so much. This thing is awesome man!
3
u/MadBoyEvo Apr 04 '19
See my newest Reddit post: https://www.reddit.com/r/PowerShell/comments/b9hvaf/dashimo_conditional_formatting_for_html_table_and/
Formatting is also added in new version.
1
Apr 04 '19
New link in my PoSH > Web favorites!
4
u/MadBoyEvo Apr 04 '19
Spread the love :-) And upvote! I do get downvotes from time to time and that's a bit depressing.
2
Apr 04 '19
Upvoted everything on those last posts, screw everyone who downvotes, they are great, easy to use functions. These are now being used in a large financial company for internal reporting for my Winsys team.
1
u/neztach Apr 02 '19
Looks great. When you get to the charts part, maybe you could add a chart logging most common account lockouts over the past x days.
3
u/MadBoyEvo Apr 02 '19
chart logging most common account lockouts over the past x days.
https://github.com/EvotecIT/PSWinReporting/issues/43 - I've created this as part of PSWinReporting. It looks for the events so most likely code responsible for generating Table with that data will be there and Dashimo will just use it.
1
u/owndy Apr 02 '19
Any hints, how can i use gmail with PsWinReporting ? Does PSWinReporting have some switches?
2
u/MadBoyEvo Apr 02 '19
What do you mean using PSWinReporting with Gmail? PSWinReporting has lots of switches ;)
If you mean sending what PSWinReporting does to Email, Teams, Slack, Sql or Dicord than yes.
https://evotec.xyz/hub/scripts/pswinreporting-powershell-module/ - start here and in the middle of the page there is Related Articles section which has lots of things described how it works and how to set it up.
If it's something else please describe ;)
2
u/owndy Apr 03 '19
Sorry about that shitty explanation. Script works great, it does make HTML, but i couldn't figure out how to set up to send e-mail through gmail .
I did setup like this, but it does not send e-mail. I think something is wrong with my parameters, but i couldn't figure out :( .
$EmailParameters = @{
EmailFrom = "<myemail>@gmail.com"
EmailTo = "<myemail>@gmail.com"
EmailServer = " smtp.gmail.com "
EmailServerPassword = "<mypasswordisdefined>"
EmailServerPasswordAsSecure = $false
EmailServerPasswordFromFile = $false
EmailServerPort = "587"
EmailServerLogin = "<myemail>@gmail.com
EmailServerEnableSSL = 1
EmailEncoding = "Unicode"
EmailSubject = "[Reporting] Event Changes for period <<DateFrom>> to <<DateTo>>"
EmailPriority = "Low" # Normal, High
2
u/MadBoyEvo Apr 03 '19
I believe gmail requires special password for smtp. You may need to check that.
1
u/Lee_Dailey [grin] Apr 03 '19
howdy owndy,
reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...
[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the resultlooks like this. kinda handy, that. [grin]
[on New.Reddit.com, use theInline Codebutton. it's4th5th from the lefthidden in the...""more" menu & looks like</>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!][1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use theCode Blockbutton. it's11th12th one & is just to the left ofhidden in the..."more" menu.]
one leading line with ONLY 4 spaces
prefix each code line with 4 spaces
one trailing line with ONLY 4 spaces
that will give you something like this ...
- one leading line with ONLY 4 spaces
- prefix each code line with 4 spaces
- one trailing line with ONLY 4 spaces
the easiest way to get that is ...
add the leading line with only 4 spaces
copy the code to the ISE [or your fave editor]
select the code
tap TAB to indent four spaces
re-select the code [not really needed, but it's my habit]
paste the code into the reddit text box
add the trailing line with only 4 spaces
not complicated, but it is finicky. [grin]
take care,
lee
1
u/goldensyrupgames Apr 02 '19
Noice. Had a look and all your other modules seem fantastic as well. Going to try them out. Thanks!
1
1
0
Apr 03 '19
[deleted]
3
u/MadBoyEvo Apr 03 '19
Use once (and on any subsequent updates when I release them)
Install-Module Dashimo -ForceAnd here's a basic example. Create file Test.ps1 anywhere and put that in:
Import-Module Dashimo $Process = Get-Process | Select-Object -First 30 Dashboard -Name 'Dashimo Test' -FilePath $PSScriptRoot\Dashboard1.html { Section -Name 'Test' { Table -DataTable $Process } }That's it. You go from there, expanding as you need it.
0
Apr 03 '19
[deleted]
3
u/MadBoyEvo Apr 03 '19
Here's more complicated example:
$Process = Get-Process | Select-Object -First 30 $Process1 = Get-Process | Select-Object -First 5 $Process2 = Get-Process | Select-Object -First 10 Dashboard -Name 'Dashimo Test' -FilePath $PSScriptRoot\Dashboard1.html { Tab -Name 'First tab' { Section -Name 'Test' { Table -DataTable $Process } Section -Name 'Test2' { Panel { Table -DataTable $Process1 } Panel { Table -DataTable $Process1 } } Section -Name 'Test3' { Table -DataTable $Process } } Tab -Name 'second tab' { Panel { Table -DataTable $Process2 } Panel { Table -DataTable $Process2 } Panel { Table -DataTable $Process2 } } }0
Apr 03 '19
[deleted]
2
u/MadBoyEvo Apr 03 '19
I am not sure how I can help you. I use this to generate HTML that I send via email or host a simple website for data visibility.
The idea is that any Object you create that you often check like that:
$Object | Format-Table -Autosizecan be output to HTML.2
u/xAretardx Apr 03 '19 edited Apr 04 '19
Here is a simple one say you are trying to get a list of all the folders that exist recursively in the users folder ie all user profiles on the machine.
$Desktop = gci "c:\Users" -Recurse | ?{ $_.PSIsContainer }| Select-Object Dashboard -Name 'Dashimo Test' -FilePath "c:\Users\Richard\Desktop\Dashboard1.html" { Tab -Name 'First tab' { Section -Name 'Test' { Table -DataTable $Desktop }}} Normally you would maybe sort this out grab only a few items from the list and kick it out into a .csv file to sort into. Instead this dumps it out into a nice html pageNow you could go deeper and do a for each folder in the users folder make a tab for that user folder and then recursively climb through that one. Now you have a nicely sorted tab for each user folder on the machine and a searchable detailed view of the contents in each location. Each one could be looked at and exported on its own to excel or csv or pdf.
Im to lazy this early to test that out but it could work nicely.
This is very cool
1
u/Lee_Dailey [grin] Apr 03 '19
howdy xAretardx,
reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...
[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the resultlooks like this. kinda handy, that. [grin]
[on New.Reddit.com, use theInline Codebutton. it's4th5th from the lefthidden in the...""more" menu & looks like</>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!][1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use theCode Blockbutton. it's11th12th one & is just to the left ofhidden in the..."more" menu.]
one leading line with ONLY 4 spaces
prefix each code line with 4 spaces
one trailing line with ONLY 4 spaces
that will give you something like this ...
- one leading line with ONLY 4 spaces
- prefix each code line with 4 spaces
- one trailing line with ONLY 4 spaces
the easiest way to get that is ...
add the leading line with only 4 spaces
copy the code to the ISE [or your fave editor]
select the code
tap TAB to indent four spaces
re-select the code [not really needed, but it's my habit]
paste the code into the reddit text box
add the trailing line with only 4 spaces
not complicated, but it is finicky. [grin]
take care,
lee0
Apr 03 '19
[deleted]
3
u/MadBoyEvo Apr 03 '19
Instead of doing $YourAdUsers | Export-CSV
You can simple use Table -DataTable $YourADUsers
After that's done you can see if output works. If it does... you can attach it to email and send. All you described is possible.
0
2
u/MadBoyEvo Apr 03 '19
Those are in the article. More examples will follow when I'll add charts and conditional formatting.
0
0
Apr 08 '19
[deleted]
2
u/MadBoyEvo Apr 08 '19
Install-Module PSWriteExcel ConvertTo-Excel -DataTable $YourObjeect -FilePath ... -ExcelWorkSheetName ... -AutoFit -AutoFilter0
Apr 08 '19
[deleted]
2
u/MadBoyEvo Apr 08 '19
Which HTML? if you don't provide Dashboard with -FilePath it will return HTML. You can always do $HTML = Dashboard {} if needed.
0
Apr 08 '19
[deleted]
2
u/MadBoyEvo Apr 08 '19
Eh :-)
ConvertTo-Excel -DataTable $ActiveUsers -FilePath ".\DASH\test.xlsx" -ExcelWorkSheetName 'test' -AutoFit -AutoFilterYou either use Dashimo or you usee ConvertToExcel.
Dashboard -Name 'Active users' -FilePath 'Dashimo.html' { tab -name 'Active users' { table -DataTable $ActiveUsers } } ConvertTo-Excel -DataTable $ActiveUsers -FilePath ".\DASH\test.xlsx" -ExcelWorkSheetName 'test' -AutoFit -AutoFilterThis gives you 2 files XLSX and HTML at the esame time.
0
Apr 10 '19
[deleted]
1
u/MadBoyEvo Apr 10 '19
As with any CSV you can do
$Object = Import-Csv -Path $YOurCSVand then do whatever you want with that object. Be it$Object | Out-HtmlViewor in full blown Dashimo it should work.0
Apr 11 '19
[deleted]
1
u/MadBoyEvo Apr 11 '19
What doesn't work? What information do you get? Did you update PSWriteHTML ? (Install-Module PSWriteHTML -Force, close powershell and open it up)? Out-HtmlView was released recently.
→ More replies (0)
0
Apr 25 '19
[deleted]
2
u/MadBoyEvo Apr 25 '19
Didn't we already solve that?
Quick Way for testing
$Data = Import-CSV -FIle <Path> Out-HtmlView $Data -FilePath ...Dashimo way:
$Data = Import-CSV -FIle <Path> Dashboard -FilePath ... { Table -DataTable $Data }And then you set it up as Task Schedule every X minutes.
0
Apr 25 '19
[deleted]
1
u/MadBoyEvo Apr 25 '19
You don't need gpedit for Task Scheduling? On each computer you have Task Scheduler which can be executed as you want it to.
0
Apr 25 '19
[deleted]
1
u/MadBoyEvo Apr 25 '19
Well, try until it works. There are some tips and tricks you need to know when it comes down to PS in Task Scheduler. But it works ;) You just need to google it properly.
6
u/Tonedefff Apr 02 '19
This looks great! I had just started on a very simple HTML dashboard project from scratch (using ConvertTo-HTML), but I might have to try out Dashimo instead, as it does a lot of the things I was planning and many I didn't think of (like exporting and search).
Some ideas/thoughts:
It would be nice to have the page automatically refresh, so you can run the .PS1 that generates the page on one computer every 5 minutes or however often, then other computers can load the HTML file via a network share and it would automatically refresh every 60-180 seconds, or whatever you want. It would also be handy to have a "Last Updated" timestamp, so you can see exactly how old the data is.
Is there a way to specify what properties of an object you want included in the table? Or would you just use Select-Object?
This is probably advanced functionality and not sure how simple it would be to implement with PSWriteHtml, but it would be great to apply conditional formatting to rows based on certain column values. For example if you had a table showing recent failed login attempts, any user with more than 3 failed logins could have its row's background color changed to red.