I have pretty much migrated to Windows Terminal as my primary PowerShell interface. Even though my daily session is PowerShell 7 I love that I can open up other sessions in the same application. yes, I know there are still limitations and that many of you prefer ConEmu. And that’s fine. Windows Terminal suits my…
Tag: PowerShell
Converting Lexical Timespans with PowerShell
I’ve been working on a few scripting projects and the data I’m working with contains lexical timespans. Say what? You have probably seen these things. This is a string like P0DT0H0M47S to represents a timespan. They aren’t difficult for humans to read. This one says “0 days 0 hours 0 minutes 47 seconds”. The format…
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…
Watching the Watcher with PowerShell
If you followed along with my recent articles about my PowerShell based backup system, you may recall that I used a PowerShell scheduled job an an event subscriber to monitor for file changes in key folders that I want to back up. I created the scheduled task to run at Windows startup and so far…
Creating a PowerShell Backup System – Part 4
We’re almost to the end of my PowerShell backup system. Last time I showed you how I handle my daily incremental backups. Today I figured I should circle back and go over how I handle weekly full backups. Remember, I am only concerned about backing up a handful of critical folders. I’ve saved that list…
Creating a PowerShell Backup System – Part 3
Let’s continue exploring my PowerShell based backup system. If you are just jumping in, be sure to read part 1 and part 2 first. At the end of the previous article I have set up a scheduled job that is logging changed files in key folders to CSV files. The next order of business is…
Creating a PowerShell Backup System Part 2
Yesterday I began a series of articles documenting my PowerShell based backup system. The core of my system is using the System.IO.FileSystemWatcher as a means to track daily file changes so I know what to backup. However there are some challenges. I need to watch several folders, I need to have an easy way to…
Creating a PowerShell Backup System
If you follow me on Twitter, you know that I have a monthly tweet reminder about running and testing backups. I have to say that the concept of a backup is different today than it was when I started in IT. Now we have cheap disk storage and cloud services. In some ways, our data…
The PowerShell Magic 8 Ball
[I updated this article to reflect minor changes in the code and the release of PowerShell 7. This article was originally published 28 October, 2019]. Last year I shared some PowerShell code on Twitter about this time of year. I have a short script that uses Windows Presentation Foundation (WPF) to create a spooky graphical…
PowerShell Scripting for Linux is Still About the Objects
I’ve been trying to increase my Linux skills, especially as I begin to write PowerShell scripts and tools that can work cross-platform. One very important concept I want to make sure you don’t overlook is that even when scripting for non-Windows platforms, you must still be thinking about objects. The assumption is that you are…