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…
Creating a Spooky Windows Terminal Theme
With Halloween fast arriving, I thought I’d share some more holiday-themed fun. Today’s entry isn’t necessarily PowerShell related but you might use it with your PowerShell work. If you’ve been kicking the tires on the Windows Terminal project from Microsoft, you might enjoy this. Here’s the finished product and then I’ll show you how to…
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…
Understanding the PowerShell 7 Ternary Operator
I’ve been writing about and teaching PowerShell from the very beginning. My focus has always been on making it easier for IT Pro to use PowerShell in their daily work to make life easier and to advance their careers. This focus has undoubtedly been challenging as the language has evolved over the years. With PowerShell…
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…
Making Sense of Parallel ForEach-Object in PowerShell 7
By, you’ve most likely heard about the new -parallel parameter with ForEach-Object in the latest preview of PowerShell 7 Personally. I’ve been waiting for this for a long time. I used to only use PowerShell workflows because it offered a way to run commands in parallel. Having this feature as part of the language is…
A PowerShell Proof of Concept with Windows Terminal
I recently updated my Windows 10 systems to the 1903 release. One of the reasons is that I wanted to try out the new Windows Terminal preview. You can find it in the Windows Store. This is bleeding edge stuff and far from complete but promises to be a great addition. Now you will be…