Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

The Ultimate PowerShell Telemetry Prompt

Posted on December 20, 2018December 20, 2018

Well, I knew I wouldn't be satisfied. The other day I shared a PowerShell prompt function that could display telemetry like information for a few remote servers. One of the drawbacks was the limited amount of information I could display. I've revised that function and have a new version that displays additional information via a few performance counters. I've also reorganized the function to make it a bit more efficient. Want to see it?

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!

Enhanced Display

This version still reads a list of computer names. I'd still recommend keeping this list brief. Although I have modified the prompt display so that each server has its own line.

an enhanced PowerShell telemetry prompt

This version of the function calls Get-Counter to retrieve additional information.

#define a list of performance counters    
$c = "\processor(_total)\% processor time",
"\physicaldisk(_total)\% disk time",
"\server\bytes total/sec",
"\system\file control operations/sec" 


#create a hashtable of counters and values
get-counter -Counter $c | select-object -ExpandProperty countersamples |
    foreach-object -Begin {$counterhash = @{}} -process {
    $counterHash.add($_.Path.split("\\")[-1], [math]::round($_.CookedValue, 2))
}

The counter data is added to the output for each server.

annotated ultimate telemetry PowerShell prompt

For visual interest, I'm using a hashtable of character values. The tricky part was padding values to get everything to line up. Even so, there may be instances where data doesn't completely line up. This generally resolves itself the next time you refresh.

Creating a One Command Session

I also am trying something new with this prompt. When you run a command, PowerShell wants to automatically invoke the prompt function. I inserted a Pause command (which only works on Windows). When you press Enter, the screen is cleared and you get your monitoring display at the top of the PowerShell console.

Displaying one command at a time

If you are only using the PowerShell console to occasionally run a command or merely want to periodically refresh the data, this might be useful. However, you can toggle this feature. When you load the prompt, PowerShell will define a global variable called PromptClear with a value of $True. Run $PromptClear = $False to turn off the pause and clear. Set it back to $True to turn it back on.

Get the PowerShell Code

By now some of you are chomping to give this a shot. The file is hosted on GitHub.

What do you think? Have I taken this concept far enough? Is this practical for any of you? What have you done to make this work for you? I hope you find this useful or at least pick up a tip or two from the code. Enjoy.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

2 thoughts on “The Ultimate PowerShell Telemetry Prompt”

  1. Pingback: The Ultimate Powershell Telemetry Prompt – Curated SQL
  2. Pingback: Maximizing My Prompt in PowerShell Core • The Lonely Administrator

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d