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.

My Daily PowerShell

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

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} 1 2 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 (120×35) and set opacity (75%). I kept the default color scheme. You can set all of these things in the system settings.

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:\ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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.

Like this: Like Loading...