As is the norm for a typical day, I was working on one thing when I was distracted by a shiny rabbit hole (to mix some metaphors). Half a day later I have a new PowerShell function that not only might you find useful, but I think it has some nice scripting features you might…
Tag: Scripting
Backing Up Windows Terminal Settings with PowerShell
I’ve been a big fan of Windows Terminal since the very beginning. In fact, I’ve been using it for so long that I’ve been moving along profile settings that have long since changed. I didn’t bother to update my settings. Part of the challenge is that the app will update in the background and I…
Importing Pester Results into PowerShell
Last week, a PowerShell scripting challenge was posted on the Iron Scripter web site. The idea was that when you run a Pester test, you can save the results to a specially formatted XML file. Invoke-Pester C:\scripts\sample.test.ps1 -OutputFile d:\temp\results.xml -OutputFormat JUnitXml I get this result. The challenge was to write a PowerShell command that could…
PowerShell Left-Center-Right
Normally, I’d leave a post like this for a Friday Fun article. But given the situation these days, I thought some of you might like to start your week off with a little fun. And maybe even learn a little PowerShell along the way. If your family is anything like mine, you are hopefully spending…
PowerShell 7 Cross-Platform Scripting Tips and Traps
One of the reasons you want to adopt PowerShell 7 on your desktop, is that it can be used cross-platform. Theoretically, you can write a PowerShell script or function that works on Windows, Linux, and Mac. However, this is not without challenges. In some ways, it feels like we are back to the early days…
Fast Folder Sizes with PowerShell
I am always looking for ways to do things faster and easier with PowerShell. One common task that I never seem to stop needing is discovering how much disk space a given folder is consuming. Even though disk space is cheap these days, I guess I’m old-school enough to want to keep things lean. It…
Better Event Logs with PowerShell
Because I don’t work in a corporate environment, I don’t always see opportunities where PowerShell can make your life better as an IT professional. I have a friend — let’s call her Gladys Kravitz. Gladys and I were chatting and she mentioned how tricky it is to pull information out of Windows event logs. If…
Creating Linked HTML with PowerShell
Today’s post is about a niche problem or something that maybe you never considered before. And while I will share a finished PowerShell function, you may want to create your own tooling based on the techniques and concepts. The problem begins with a command like this: Get-HotFix -ComputerName $env:computername | Sort-Object Description,InstalledOn -Descending | Select-Object…
Friday Fun: Taking a Shortcut Path in Your PowerShell Prompt
To kick off the new year I thought I’d take a shortcut and reclaim some wasted space in my PowerShell prompt. I know I run into this issue during classes and conferences. Perhaps you encounter it as well. You are in in the PowerShell console and have ended up in a deep directory structure so…
Managing My PowerShell Backup Files
Last month I started a project to begin backing up critical folders. This backup process is nothing more than another restore option should I need it. Still, it has been running for over a month and I now have a number of full backup files. I don’t need to keep all of them. If I…
PowerShell Paths and Errors
As you write PowerShell scripts, it is important that you include error handling. Most of the time, this involves the use of Try/Catch statements. The tricky thing with Try/Catch is that you can only catch a terminating exception. There are a few cmdlets that by design will throw a terminating exception. But you have no…
My PowerShell Hyper-V Health Report
Over the last few years I’ve been using and tweaking a PowerShell script that generates an HTML report that provides information about a Hyper-V host and running virtual machines. This is another great use case for a PowerShell control script. The script helps me organize commands like Get-CimInstance, Get-VM and Get-Counter to retrieve pieces of…
Managing the Recycle Bin with PowerShell
A while ago, I posted an Iron Scripter challenge asking you to write some PowerShell code for working with items in the recycle bin. You were asked to calculate how much space the recycle bin is using and then restore a file. If you’d prefer, stop reading this post, check out the challenge and see…
Friday Fun: Getting Ahead with Windows Terminal
I’ve been using the new Windows Terminal from Microsoft for quite while. In fact, it has become my standard command line interface for PowerShell and more. I’m not sure at what point some of these features were added, but I can now set a background image and specify where to display it in the terminal….
PowerShell Controller Scripts
When it comes to PowerShell scripting we tend to focus a lot on functions and modules. We place an emphasis on building re-usable tools. The idea is that we can then use these tools at a PowerShell prompt to achieve a given task. More than likely, these tasks are repetitive. In these situations, it makes…