The other day I shared my PowerShell plans for 2022. And needless to say, I didn’t wait to dig in. I am working on a new module and since it won’t be published until next month, I went ahead and marked it as Core only. I also started writing a set of Pester 5.x tests…
Tag: Function
Converting PowerShell Scripts to Functions
Recently, I shared some PowerShell code to export a function to a file. It was a popular post. My friend Richard Hicks (no relation) thought we was joking when he asked about converting files to functions. His thought was to take a bunch of PowerShell scripts, turn them into a group of functions which could…
Exporting PowerShell Functions to Files
When I write a PowerShell module, it typically includes more than one export function. Where you store your module functions is a great discussion topic and I don’t think there is necessarily one best practice for everyone. I think it might depend on the number and complexity of the functions. Are other people contributing code…
Friday Fun: PowerShell Console Editing
The other day I read an interesting article on Adam Bertram’s blog about editing files with a text editor in PowerShell. Naturally, the PowerShell wheels in my head began turning. While I was intrigued by some of the options in the article, I’ve in fact installed the Micro editor to play with, I realized I…
Generate PowerShell Dynamic Parameter Code
One of the topics we’ve discussed in the PowerShell Cmdlet Working Group is a request to make it easier to insert dynamic parameters. I am a bit torn on this. On one hand, I see the value in dynamic parameters. These are parameters that only exist if some condition is met, such as if the…
Finding Modified Files with PowerShell
Here’s another task that I seem to be constantly fiddling with using PowerShell. What files did I work on yesterday? Or what files were modified in the last 48 hours? Obviously, Get-ChildItem is going to be the primary command. It is simple enough to get files based on an extension from a given folder path,…
Update Registry OS ProductName with PowerShell
I expect many of you are like me and have done, or will do, an in-place upgrade from Windows 10 to Windows 11. It is easy enough to run a PowerShell expression like this to see the operating system name. I get a value like Windows 11 Pro. However, operating system information is also stored…
There’s a File in My PowerShell Bucket
If there’s one task I’ve never stopped doing, it is finding files. I am constantly creating new ways to organize files and display them in a meaningful format. Naturally, PowerShell is a great tool for this task. Get-ChildItem is obviously the proper starting point. The cmdlet works fine in getting only files from a folder…
Extending PowerShell PSDrives
Yesterday I shared some PowerShell code I use to managing my PSDrive assignments. My code works for me in my environment. But that doesn’t mean it is necessarily right for you and your environment. There are plenty of ways to use PowerShell to achieve the same results as my code. This is something you should…
Cleaning Up PowerShell Jobs
I am a heavy user of PowerShell jobs. Not only background jobs but also scheduled jobs. They are a critical element in my daily workflow. Every time a job runs, especially scheduled jobs, a job artifact remains which you can see using Get-Job. For scheduled jobs, I try to keep this to a minimum by…
Hiding TaskBar Search with PowerShell
Yesterday I shared a few PowerShell functions for configuring the Windows 10 taskbar to auto-hide. This works great in my virtual desktop when recording my Pluralsight courses. But even when hidden I would still get an annoying white sliver from the search box. So I got rid of that as well. Here are some PowerShell…
Managing the Windows 10 Taskbar with PowerShell
When I’m working on a Pluralsight course, I tend to setup a virtual machine for recording. Although, lately I’ve been trying with Windows 10 Sandbox. This is handy when all I need is a Windows 10 desktop. When I setup the system, I have particular settings I need to configure. Naturally I use a PowerShell…
Custom CSV Import with PowerShell
I am always looking for opportunities to use PowerShell in a way that adds value to my work. And hopefully yours. This is one of the reasons it is worth the time and effort to learn PowerShell. It can be used in so many ways beyond the out-of-the-box commands. Once you understand the PowerShell language…
PowerShell Event Log Mining
The other day someone who is learning PowerShell reached out to me with a problem. He couldn’t understand why the relatively simple PowerShell expression to pull information from the System event log wasn’t working. He wasn’t seeing errors, but he also wasn’t seeing the events he was expecting. Searching event logs with PowerShell is a…
Friday Fun: Counting Down Events with PowerShell
We just finished a very successful virtual edition of the PowerShell+DevOps Global Summit. We lost our 2020 event to the pandemic but fortunately, the people at The DevOps Collective were able to pull together a fantastic virtual event. There were as many virtual attendees as we normally have at the in person event. But of…