I’ve been working on a new PowerShell module that incorporates code from a few of my recent posts on converting PowerShell scripts and functions to files. I even whipped up a script, think of it as a meta-script, to create the module using the commands that I am adding to the module. I’ll cover that…
Tag: PowerShell
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…
Creating a PowerShell Clock
I’ve published a new project to the PowerShell Gallery. This is something that I needed, and maybe you do as well. Even though I have the typical clock running in the Windows taskbar, I have an ultrawide monitor so it isn’t always easy to read. I had been running the xclock app from WSL which…
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…
Removing Obsolete PowerShell Remoting Configurations
I’m pretty sure I’ve discussed this before, but Microsoft is scheduled to release PowerShell 7.2 soon, I thought it might be good to revisit this topic. Here’s the potential issue. If you’ve been installing PowerShell 7 releases for a while, and have been enabling PowerShell remoting, you most likely have a list of remoting session…
Friday Fun: A PowerShell Welcome
I realized it had been a while since I wrote a Friday Fun post. These posts are intended to demonstrate PowerShell in a fun and often non-practical way. The end result is generally irrelevant. The PowerShell scripting techniques and concepts I use are the real takeaways. The task is nothing more than a means to…
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…
I Need a PSDrive Now!
I hope you’ve been enjoying the last few posts on working with PSDrives. To round out the set, I thought I’d remind you of a command in the PSScriptTools module that I use often, especially when teaching a live class or presenting at a conference. As you’ve seen, I use PSDrives as shortcuts to commonly…
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…
Fun with Mapping PowerShell Drives
Because I spend my day working from a PowerShell prompt, I rely heavily on PSDrives to quickly access files and folders. And because I am mobile, I might be working at my desk in my home office, or I might be on the road with my trusty Thinkpad. Of course, this means, I want an…
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…
Doing More with $MyInvocation
Not that long ago someone made a comment to me on Twitter about something I had shared related to PowerShell. He wanted to know more about the $MyInvocation variable. This is something that isn’t well documented, yet can be very useful in your PowerShell scripting. Let’s take a look at it in a bit more…