PowerShell Community
A place for the community to learn PowerShell and share insights
Latest posts
Encrypting secrets locally
Keeping security folks happy (or less upset which is the best we can hope for)
Simple form development using PowerShell
Create .NET forms without all the .NET.
Creating a scalable, customised running environment
This post shows how to create an easy to support environment with all your own cmdlets.
Using PowerShell and Twilio API for Efficient Communication in Contact Tracing
Learn to integrate PowerShell with Twilio API and streamline communication for COVID-19 contact tracing initiatives.
Automate Text Summarization with OpenAI and PowerShell
This easy-to-follow guide shows you how to use PowerShell to summarize text using OpenAI's GPT-3.5 API.
Changing your console window title
This post shows how to change the title of your console terminal window.
Measuring average download time
This post shows how to measure average download time with PowerShell
Measuring script execution time
This post shows how to measure script execution time in PowerShell
Porting System.Web.Security.Membership.GeneratePassword() to PowerShell
This post shows how to port a C# method into PowerShell
Designing PowerShell For End Users
This posts explains taking user experience into account when designing PowerShell tools
Convert specific table of excel sheet to JSON using PowerShell
This posts explains how to Convert Specific Table of Excel Sheet to JSON
Update XML files using PowerShell
This posts explains how to update XML files using PowerShell
Mastering the (steppable) pipeline
The PowerShell pipeline explained from the beginning to the end.
PowerShell Registry Monitor
How to set up a simple registry key monitor with PowerShell
The many flavours of WMI management
Working with the different ways of managing WMI.
Password Expiry Notification Using Teams and Graph API
This post's intent is to show how to use Graph API through PowerShell to send a Teams message.
Cheat Sheet – Console Experience
How to have more control of preferences in functions and the role of modules on inheritance.
Reading Configuration Manager Status Messages With PowerShell
This post's intent is to show how to read Configuration Manager status messages using WMI and Win32 API function FormatMessage.
On Preferences and Scopes
Progress in PowerShell: a tale of Verbosity and other preferences with lessons in Scopes and Proxies thrown in It started, as these things often do, with someone complaining. In PowerShell Version 7.2 the output of and look like this: In all the earlier versions they look like the version below, which is more helpful when you're trying to debug code that builds URIs: A proxy function will fix that. If two commands have the same name an alias beats a function, which beats a cmdlet, which beats an external program. You can specify the full path to an external program or cmdlet - for example so an functio...
How to Preview PowerShell Scripts In PowerShell
Q: When I use Windows Explorer and select a PowerShell script file - I do not see the script in the preview window. Can I fix that? A: You can make a few simple registry updates and do just what you want! At some time in the deep and distant past, Windows Explorer gained the preview pane feature. The idea is simple: you select a file in Explorer and Windows shows you a preview of the file in a separate pane. I love this feature, although when clicking on a Word document, it could take a few moments before I could view. And if you are viewing a file, it was "open" and you could not delete it in a separate window...
How to Use $PSDefaultParameterValues
Q: When I use cmdlets like and , how do I change default values of the Keep and Wrap parameters? A: Use the automatic variable. When I first discovered PowerShell's background jobs feature, I would use to view job output - only to discover it's no longer there. And almost too often to count, I pipe objects to cmdlet only to get truncated output because I forgot to use . I'm sure you all have parameters whose default value you would gladly change - at least for your environment. I'm sure you have seen this (and know how to use Wrap), like this: So, the question is: how to tell PowerShell to always use w...
How to Use $FormatEnumerationLimit
Q: When I format an object where a property contains more than 4 objects, I never see the extra property values. How can I fix that? A: Use the variable. This query is one I hear in many PowerShell support forums, and I have encountered this issue a lot over the years. What happens is that you issue a command to return objects, for example . The cmdlets return objects which can contain properties that are arrays of values, not just a single value. When you pipe those objects to , by default, PowerShell only shows you the first four. Let me illustrate what this looks like (by default): This output shows Po...
How to use the Secret modules
Q: I have a bunch of scripts we use in production that make use of Windows credentials. In some cases, these scripts have an actual password in plain text, while others read the password from an XML file. Is there a better way? A: Scripts with high-privilege account passwords in plain text is not a good idea. There are several methods you can use to improve the security of credentials handling. One great way is to use the SecretManagement and SecretStore modules from the PowerShell Gallery. What are Secrets? Secrets are, in general, passwords you need to access some resource. It might be the password for a dom...
A closer look at the Crescendo configuration
In my previous post, I looked at the details of a Crescendo output handler from my VssAdmin module. In this post, I explain the details of a cmdlet definition in the Crescendo JSON configuration file. The purpose of the configuration The structure for the interface of a cmdlet is a reasonably predictable thing. The pattern of the script code to support these fits a template. The more difficult part of the cmdlet is in the code that does the work. Crescendo separates the functional code (the output handler) from the cmdlet interface code. The Crescendo configuration file defines the interfaces of cmdlets...
A closer look at the parsing code of a Crescendo output handler
In my previous post, I showed you how to parse the output from the command. The output of is not very complex. The goal of the post was to introduce some parsing strategies that you can use to create a full Crescendo module. In this post, I explain the details of a more complex parsing function that I created for my VssAdmin module. Examining the parser for The following screenshot shows the function that is called by the cmdlet to handle the output from . The parsing process is broken into four areas: Collecting the native command output The output from is passed into the output handler functi...
Converting string output to objects
In my previous post, I talked about using Crescendo to create a PowerShell module for the command in Windows. As I explained, you have to write Output Handler code that parses the output of the command you are using. But if you never written a parser like this, where do you start? In this post I show you how to parse the output from the command. The output of is not very complex and it is basically the same on Windows and Linux systems. The goal here is to talk about parsing strategies that you can use to create a full Crescendo module. Step 1 - Capture the output To create a parser you have to capture the ...
Understanding Get-ACL and AD Drive Output
Understanding Active Directory ACL using PowerShell can be a bit tricky. There are no out-of-the-box cmdlets with ActiveDirectory PowerShell module to help in settings the permission quickly. While there are no cmdlets, you can nevertheless manage AD permissions using the AD PowerShell drive. In this post, I will try to simplify Active Directory ACL and how to read the result easily, so let's start. Prerequisites To follow along with this article, you need the following: The domain name used for this tutorial is Contoso.com. Reading Active Directory Permission using Get-ACL Reading Active Directory pe...