March 2025 PowerShell Potluck
Welcome back to another monthly PowerShell round-up. We skipped February. Let's see what's new in the PowerShell world that might interest you.
RunAs Radio
I recently did an interview with Richard Campbell on RunAsRadio. This is a weekly podcast for IT Professionals and one you should be listening to. We chatted about PowerShell and PowerShell toolmaking, mentioning many of the topics I cover here about crafting better PowerShell tools. You can find Show #977 on line or in your favorite podcast app. I'd love to hear what you think.
PoshTaskbarItem
Here's another PowerShell tool from the crazily creative mind of mdgrs-mei, the creator of PowerShellRun which I use daily and have mention before. I hope you'll give the module PoshTaskBarItem a try. The module is supported in Windows PowerShell and PowerShell 7. The module lets you create taskbar items using PowerShell. I'll give you an example.
First, you need to install the module.
Install-PSResource PosTaskBarItem
You don't run module commands directly in the console. Instead, you will use the commands in a PowerShell script. Here is a script I wrote to display memory usage in a taskbar icon.
#requires -version 5.1
#requires -RunAsAdministrator
#requires -module PoshTaskbarItem
#C:\Scripts\memory-monitor.ps1
#revised from https://github.com/mdgrs-mei/PoshTaskbarItem/blob/main/Examples/MemoryMonitor.ps1
$linkPath = "$env:userprofile\Desktop\PSMemoryMonitor.lnk"
$iconPath = "c:\windows\system32\imageres.dll"
# Install shortcut on first run
if (-not (Test-Path $linkPath)) {
$params = @{
Path = $linkPath
IconResourcePath = $iconPath
IconResourceIndex = 144
TargetPath = 'pwsh.exe'
Arguments = ('-ExecutionPolicy Bypass -WindowStyle Hidden -File "{0}"' -f $MyInvocation.MyCommand.Path)
WindowStyle = 'Minimized'
}
New-TaskbarItemShortcut @params
return
}
$params = @{
Title = 'MemoryMonitor'
IconResourcePath = $iconPath
IconResourceIndex = 144
OnClicked = {
Start-Process 'Taskmgr.exe'
}
}
$ti = New-TaskbarItem @params
Set-TaskbarItemTimerFunction -InputObject $ti -IntervalInMillisecond 5000 -ScriptBlock {
$os = Get-CimInstance Win32_OperatingSystem
[Int]$usage = 100 * ($os.TotalVisibleMemorySize - $os.FreePhysicalMemory) / $os.TotalVisibleMemorySize
$processes = Get-Process | Sort-Object -Property WorkingSet -Descending
$top5 = $processes[0..4]
[string]$processNames = $top5.Name -join "`n"
$color = 'LightSeaGreen'
if ($usage -ge 50)
{
$color = 'DeepPink'
}
Set-TaskbarItemOverlayBadge -InputObject $ti -Text $usage -FontSize 10 -BackgroundColor $color -badgeSize 20 -FrameWidth 2
#the popup description won't display in Windows 11 24H2
Set-TaskbarItemDescription -InputObject $ti -Description $processNames
}
Show-TaskbarItem $ti
When you run the script, it will create a desktop icon if it doesn't already exist. You can then use the shortcut to run the command. Or, if you re-run the script it will create the taskbar item. However, the reason for the desktop shortcut is that running the script interactively will block your prompt until you close the task bar item.
It might take a minute for the taskbar item to appear.

The taskbar item will show the memory usage in the taskbar icon. You can click on the icon to open Task Manager. If you hover over the icon, the code is supposed to display the top five process names. Unfortunately, Windows 11 24H2 changed something and broke this functionality. Close it like you would any other taskbar item.
The PostTaskBarItem
module is a framework for creating your own PowerShell-based taskbar items. I hope you'll give it a try and let me know what you come up with.
Warped PowerShell
Another item that came to my attention last month was a terminal replacement called Warp. This a console replacement with AI built-in. Some of the features require a paid subscription but you should be able to get a good sense of the product from the free version.
To install, download from https://www.warp.dev/download or use winget
winget install warp.warp -s winget
This will install a new app.

Launching it will open use a DOS prompt. Like Windows Terminal, it will detect other possible shells.

You can type commands in the prompt and see results in the output pane above.

The fun part is that AI is built-in. Click on Pair
and select a language model.

I asked for help in creating a regex pattern.

There is so much that you can do with this app that can really accelerate your work. I'm happy with simple things like file management. I love that I can open Markdown files directly in the app to view them.

Expect to spend some time learning how to get the most from this app. You'll find the documentation at https://docs.warp.dev/getting-started/what-is-warp to help you get started.
A New Scripting Challenge
I gave you a break, but I think it is time for another PowerShell scripting challenge. This is an opportunity to maybe learn something new and re-enforce the skills you already have. This month's challenge is another cipher project. You might find the last cipher-related scripting challenge to help you this month.
What I have is a variation on the classic Caesar cipher. This is a simple character substitution cipher. The difference is that you take the letters from a key work and insert them at the beginning the alphabet. This has the effect of "shifting" the letters and changing the order of the letters.
For example, I'll use these variables.
$plaintext = "I am the walrus"
$key = "powershell"
$alpha = "abcdefghijklmnopqrstuvwxyz"
The unique key letters in the key are 'powershl'. These letters are removed from $alpha
and inserted at the beginning.
$alphaShifted = "powershlabcdfgijkmnqtuvxyz"
To encode the plain text, find the letter in $alpha
and replace it with the letter in $alphaShifted
at the same index. The result is a new string.
$alphaShifted = "powershlabcdfgijkmnqtuvxyz"
$alpha = "abcdefghijklmnopqrstuvwxyz"
<#
I = a
a = p
m = f
...
#>
Joining the letters together gives you the encoded string, a pf qlr vpdmtn
. Your challenge is to write a set of PowerShell functions to encode and decode a short string. To keep it simple, only worry about encoding/decoding a string with letters only and don't worry about maintaining case.
For a more advanced challenge, write functions that support numbers, punctuation, and maintains casing.
Good luck!
Thank You
Thank you again for supporting my work. If you need to manage your subscription, use the links in the email footer. I especially hope free subscribers will consider upgrading to a premium subscription to see everything you've been missing. You can cancel at any time.
See you next month.