This is small demo where I combined PowerShell + HTML to create a dashboard report for ping. Basically what it does is? when you put some servers entries in Pinglist.txt file which you want to ping and start a PowerShell Get_PingData.ps1 script. It shows the Live Dashboard on HTML web page as per server list. When you hover on any of the server, it will show more information such as IP address.
Other useful article based on this: PowerShell HTML Server Racks Cabinet Live Diagram maker Demo
Below is the small demo video about this script. Ping result boxes are dynamic and are added or removed as per the servers in Pinglist.txt automatically. This dashboard is not only limited to ping, you can monitor services and other object with modifying PowerShell Script.
How to implement this script?
To use this app you will need to host the files (shared on github) on a Web Server. As web server I am using Microsoft Windows IIS (Internet Information Services) web server. As a first step I will install it from a scratch on Windows server.
Search and Open Windows PowerShell - Run as administrator.
Next run below command to install IIS (Internet Information Services) web server and its components. It doesn't need Reboot/Restart and Exit code should be Success and Success should be True after running command.
Install-WindowsFeature Web-WebServer, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing, Web-Http-Errors, Web-Static-Content, Web-Health, Web-Http-Logging, Web-Performance, Web-Stat-Compression, Web-Security, Web-Filtering, Web-Mgmt-Tools, Web-Mgmt-Console -IncludeManagementTools
Download the HTML and PowerShell code zip file from my github account.
$zipUrl = 'https://github.com/janviudapi/PowerShell/raw/master/HTML/Web_Based_Live_Ping_Monitor_Dashboard/live4.1.zip' Invoke-WebRequest $zipUrl -OutFile $home\Downloads\live4.1.zip
When IIS is install, it's default website and component contents are installed and configured under folder C:\inetpub. Folder wwwroot is web root folder where html static file exist.
Extract downloaded live.4.1.zip file under C:\inetpub\wwwroot\live. Basic Web Server and HTML configuration is done.
There is a file Get_PingData.ps1 in the folder, unblock it (This file came from another computer and might be blocked to help protect your computer).
I have highlighted the files and folder structure for better understanding. Only yellow highlighted file I am going to edit, and execute red highlighted Ps1 script.
Next open the Pinglist.txt file and add your servers which you want to ping, all the servers are docker containers.
You are all set to execute Get_PingData.ps1 file (no changes are required in this script file), I have written this script for PowerShell Version 7, if incase you don't have v7 installed on you IIS server, you can download and install it using below commands. This will setup your environment.
$powershellDownbload = 'https://github.com/PowerShell/PowerShell/releases/download/v7.3.4/PowerShell-7.3.4-win-x64.msi' $msiPath = "$home\Downloads\PowerShell.msi" (New-Object System.Net.WebClient).DownloadFile($powershellDownload, $msiPath) $tmpFileName = [System.IO.Path]::GetTempFileName() Star-Process msiexec -ArgumentList "/i $msiPath /qn /L*v $tmpFileName" -NoNewWindow -Wait
Once PowerShell is installed, Next search for PowerShell 7 and Run as administrator.
Execute below command to start collecting ping data. Basically it collects the data and keep it in a file with JSON format and keep on updating it until you stop the ps1 script.
. C:\inetpub\wwwroot\live\Get_PingData.ps1
You can watch and monitor your dashboard now in browser with http://localhost_ip_fqdn/live. As you modify the pinglist.txt file as the dashboard will update it self according to list.
Download this script live_ping_monitor.zip here or it is also available on github.com/janviudapi.
Useful Articles
Powershell adding leading zeros to string or int
PowerShell convert string to base64 value
PowerShell Encode or Decode an WebURL
Create an interactive HTML report with PowerShell data
Executing PowerShell script from PHP HTML web server
Send system disk space utilization HTML report Email using PowerShell
Send Email using PowerShell with .net object System.Net.Mail.MailMessage