Powershell

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 {...

Displaying Input Box

If you’d like to open a quick and dirty input box to prompt a user for some data, you could access Microsoft Visual Basic and...

Reading Text Files Fast

There are plenty of ways how PowerShell can read in text files, and they can differ considerably in time. Check for yourself. The examples below...

1 24 25 26 27 28 104