Windows PowerShell Tips

Archived by Date

Helpful tips for working with Windows PowerShell, archived by date. (Switch to see this archive by category.)


June 2008

Three Things You Might Not Know About Windows PowerShell Functions

Default values, piping, scope…all that plus some bonus information, all things you should know about working with functions in Windows PowerShell.

Taking Things (Like File Paths) Literally

Need to work with file names and paths with odd characters in them? Not a problem in Windows PowerShell.

Using Test-Path to Verify the Existence of an Object

Find out if files, folders, variables, etc., exist by using the Test-Path cmdlet.

Formatting Numbers and Dates Using the CultureInfo Object

Format numbers and dates to a specific culture setting, no matter what the current machine settings are.


May 2008

Finding All the Empty Folders in a Directory Tree

This tip shows you how to-well, how to find all the empty folders in a directory tree.

Displaying a Message in the Notification Area

Display an icon and a message, and even change the message, in the Windows Notification area.

Working with Security Descriptors

Setting security descriptors gets a lot easier when you use the .NET Framework.

Multi-Select List Boxes-And More!

You know how to create a list box (or at least you do if you read the tip directly above this one), now find out how to fancy it up a bit by making it multi-selectable and even a little colorful.

Selecting Items From a List Box

Create a form that displays a list box from which users can select.


April 2008

Using Calculated Properties

No kilobytes? No problem. At least not when using calculated properties.

Filtering Collections with Regular Expressions

Data retrieval for those times when the wildcard character just isn’t enough.

Working with Custom Objects

Create-and use-custom objects within your PowerShell scripts.

Determining the Size of a Folder

A simple task that turns out not to be so simple, then turns out to be simple again.


March 2008

Listing the TrueType Fonts Installed On Your Computer

Here’s the real PowerShell way to get all the TrueType fonts on the computer, and list them in an Internet Explorer window.

Making Progress

Want to know how much longer your script will be running? Try displaying a progress bar.

Creating a Graphical Date Picker

Learn how to display a date control that allows the user to choose a date.


February 2008

Creating a Custom Input Box

An introduction to creating graphical user interfaces with Windows PowerShell.

Working with SIDs

Find the Security Identifiers (SIDs) for local and Active Directory users; or, conversely, find the user associated with an SID.


January 2008

Adding a Simple Menu to a Windows PowerShell Script

Display options to the user and take actions based on the option chosen.

Pausing a Script Until the User Presses a Key

Display the “Press any key to continue…” message and wait.

Using the Switch Statement

Learn about one of the coolest things about Windows PowerShell-the switch statement.

Creating Formatted HTML Output

Find out how useful the ConvertTo-HTML cmdlet can really be.


December 2007

Creating and Modifying Environment Variables

Create and modify process-level, user-level, and machine-level environment variables.

Getting Information About the Logged-On User

Get information about the logged-on user and the local computer, the easy way.


November 2007

Getting Rid of a COM Object (Once and For All)

Sometimes COM objects stick around a little longer than we’d like. Find out how to get rid of them for good.

Automatic Script Writing with Get-History

Tired of writing your own PowerShell scripts? Then ask the Get-History cmdlet to write those scripts for you.


October 2007

More Fun with Dates (and Times)

How to use the Get-Date cmdlet to retrieve many different elements of dates and times. Plus, a bonus script that looks at using the .NET Framework to retrieve date and time information.

Running Scripts Against Multiple Computers: Part 2

Running scripts against all the computers in a domain; all the computers in an OU; or all the computers listed in an Excel spreadsheet.

Running Scripts Against Multiple Computers

Use command-line arguments, text files, and even a prompt to read in computer names and run a script against each computer.

Reading Text Files

Don’t feel bad: Everyone you know still uses text files, too.


September 2007

Modifying a Read-Write Property Using Get-WMIObject

Don’t let them kid you: you really can modify a read-write property using Get-WMIObject.

The String’s the Thing

An entire tip devoted to strings. Compare two strings, change casing, read parts of strings-even turn a string into an array.

Working with Hash Tables

Store key-value pairs, add and remove items, and sort on key or value.

Removing Items From Arrays

Who said you can’t remove an item from an array? You just need to use the right type of array.


August 2007

Formatting Dates and Times

Modifying the display of date-time values.

Calculating Text File Statistics

Determine the number of words, lines, and characters in a text file.

Modifying Message Colors

Change the background and foreground color of messages (warning, error, etc.).

Finding Values in an Array

How can you tell if a given value exists in a Windows PowerShell array? Here’s how.

Even More Things You Can Do With Arrays

Tips and tricks for creating new arrays (including empty arrays and strongly-typed arrays) in Windows PowerShell.


July 2007

Cool Things You Can Do With the Get-ChildItem Cmdlet

Retrieve hidden files; retrieve files from multiple folders; and much, much more.

Formatting Numbers

Displaying numbers in a more-readable format.

Creating Custom Tables

Creating custom tables using the Format-Table cmdlet.

Using the Range Operator in Wildcard Queries

Using PowerShell’s range operator in conjunction with cmdlets such as Get-ChildItem.


June 2007

Using Windows PowerShell “Here-Strings”

Assigning multi-line string values to a variable.

Accessing Values in an Array

Accessing specific values-and ranges of values-within an array.

Referencing Variables and Variable Values

Embedding variables directly in your strings.

Byte Conversion

Converting bytes to megabytes to gigabytes, etc.

Top of pageTop of page