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

Maximizing My Prompt in PowerShell Core

Posted on January 10, 2019January 23, 2019

Yesterday I wrote about my intention to make PowerShell Core, running on Windows 10, my "daily driver". I've also written recently about using the PowerShell prompt function to provide a wide range of information. So I decided to combine the two, plus mix in some functionality from my other PowerShell tools, to create a PowerShell console with everything at my fingertips. I'm going to walk you through the process of duplicating the prompt, although you may elect to skip certain features. Along the way I'll point out what modules you'll need to install from the PowerShell Gallery. These projects are all on GitHub as well so you can check them out before installing. The code for my PowerShell prompt function is admittedly complex and if you want to customize it, you'll need some PowerShell scripting experience. Or perhaps you want to duplicate my experience . In either case, let's dig in.

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!

My Daily PowerShell

Before I go through the steps I thought you might like to see the finished product.

My PowerShell Core daily prompt

The display shows the computer name with the current date and time. A list of upcoming events, a calendar with highlighted event days and some system information: uptime, percent free space on C:, percent free memory and the total number of running processes. I should point out that the finished prompt will also run on Windows PowerShell. I just happen to be using it with PowerShell Core. Still interested? You'll need to set up some additional tools.

MyTickle

I have a module that I use to keep track of upcoming events like phone calls, meetings or other items I want to make sure I don't forget. This module provides a tickler system to help me remember. You can read all about it on the GitHub repository. This module will require some sort of SQL Server backend. I recommend you install the free SQL Server Express edition. Install using the default settings so that the instance name is SQLExpress. That is the path of least resistance to use this module. Otherwise, read through the help to see how to customize. Use the c: command to set it up.

You can then use Add-TickleEvent to define some reminders. My prompt function will display events due in the next 10 days. Those that are due in a day or less will be displayed in red. If it is due in 48 hours it will be displayed in yellow otherwise the reminder shows in green. Events due in the next 30 days will be used to populate the calendar.

PSCalendar

Next you'll need my PSCalendar module, at least version 1.5.0. The Show-Calendar command will be used within the function to display a colorized month. Tickle events for the next 30 days are used as highlight dates for the calendar. Of course the module has other calendar commands you might like to use.

Customizing the PowerShell Core Window

I'm going to assume you've already downloaded and installed PowerShell Core on your Windows desktop. You can use my PSReleaseTools module to make this an easier process.

get-psreleaseasset -Family Windows -Only64Bit | where format -eq msi | 
Save-PSReleaseAsset -Path C:\PS6 -Passthru | foreach { invoke-item $_.fullname}

Once installed, launch PowerShell Core. I tend to always run it in an elevated session but I work at home and don't have a critical production network to worry about.  I modified my  Window to increase the font size (24) , font (Consolas), window/buffer size (120x35) and set opacity (75%). I kept the default color scheme. You can set all of these things in the system settings.

Setting window properties

The Prompt Function

The last piece of the puzzle is the prompt function itself. I have put the complete prompt function on Github.

Download a copy and edit it as you need to. I've tried to insert comments to help you remove features you may not want to use. To automatically load the prompt edit or create the profile script for the current user current host and dot source the path the prompt function.  To fully duplicate what I am doing you might also might want to add a few more bells and whistles.

import-module myTickle
import-module PSCalendar

$PSDefaultParameterValues.Add("Get-Calendar:Highlightdate", (Get-TickleEvent -days 30).date.toshortdatestring())
$PSDefaultParameterValues.Add("Show-Calendar:Highlightdate", (Get-TickleEvent -days 30).date.toshortdatestring())
. c:\scripts\dailyprompt.ps1

function Test-IsAdministrator {  
    $user = [Security.Principal.WindowsIdentity]::GetCurrent();
    (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)  
}


if (Test-IsAdministrator) {
    $n = "Administrator"
}
else {
    $n = "Non-Admin"
}
[console]::Title = "$($n): PowerShell $($psversiontable.psedition) $(([regex]"\d+\.\d+.\d+").match($psversiontable.psversion).value)"

Set-Location C:\

To simplify things, I'm setting some default parameter values so that the calendar will default to highlighting my tickle events. I also have some code that sets the window's title bar. If all goes well, when I start PowerShell Core, I should see my display. Although I should point out that on first load there is some background work so you won't see performance stats for a minute or so until you press Enter again. Expect that you might need to tweak a few settings.

PowerShell Your Life

I'll admit I may go a little overboard with integrating PowerShell into my life. You may not be nearly as maniacal! Still, the process in building all of this is a great learning opportunity. I hope it is for you. Take the time to go through the modules and function. See how I am integrating the different pieces. I hope it provides a better understanding of how PowerShell works and how you can build your own tools to help PowerShell manage your life.


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 “Maximizing My Prompt in PowerShell Core”

  1. Brien Posey says:
    January 17, 2019 at 7:25 pm

    As someone who lives and breathes PowerShell, I just had to reach out and tell you how cool I think your idea is.

    Cheers,
    Brien

    1. Jeffery Hicks says:
      January 17, 2019 at 8:01 pm

      Thanks. This is definitely taking things to an extreme. So far I’ve found it helpful.

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