powertips

Using AD Filters with Cmdlets (Part 1)

The free RSAT tools come with the ActiveDirectory PowerShell module. You can use the cmdlets from this module to retrieve AD information such as...

Creating Temp File Names

Whenever you write information to disk, it makes sense to use unique temporary file names. If you use static file names and run your code more than...

File System Stress Test

If you’d like to generate super large files for stress test purposes, you don’t have to waste time pumping data into a file to make it...

Passing Commands via Parameter

Here is a rather unusual use case for function parameters: a user can pass an output command: function Get-ProcessList { param ( [string]...

Dealing with File Encoding and BOM

When you write text content to a file, PowerShell cmdlets let you specify the encoding. Encoding determines how characters are stored, and when...

Progress Bar Timer

Here is a simple example using the PowerShell progress bar. The code displays a progress bar counting down a break. Simply adjust the number of...

Exchanging Variable Values

Here’s a quick tip how to switch variable content in one line: $a = 1 $b = 2 # switch variable content $a, $b = $b, $a $a $b ReTweet this...

Using Default Parameters

If you find yourself always using the same parameter values over again, try using PowerShell default parameters. Here is how: # hash table # Key = #...

Finding Executable for File

Most things can be handled by built-in PowerShell commands, but if that’s not enough, you can always resort to the internal Windows API. For...

Adding Leading Zeroes

If you need numbers with leading zeroes, for example for server names, here are two approaches. First, you can turn the number into a string, then...

Displaying Message Box

If you’d like to show a default MessageBox with some buttons for the user to click, try this function: function Show-MessageBox {...

1 18 19 20 21 22 98