powertips

Create ASCII Art

It’s amazing how versatile PowerShell is: with just a couple of lines of code, you can turn any photo and image into a piece of ASCII art....

Verifying Local User Account Passwords

In the previous tip, we asked Active Directory to validate user account passwords. The same can be done with local accounts. Your PowerShell code...

Converting Text to Image

WPF (Windows Presentation Foundation)is not just a technique to create UIs. You can create any type of vector-based graphics composition and save it...

Removing BOM from the Unicode Files

BOM (Byte Order Mask) is a characteristic byte sequence used in some Unicode encoded text files. If you receive text files with BOM that need to be...

Get Text File Encoding

Text files can be stored using different encodings, and to correctly reading them, you must specify the encoding. That’s why most cmdlets...

SID of Current User

Here is a one-liner that returns the SID for the current user and can be used in logon scripts, for example:...

Formatting Date and Time (with Culture)

In the previous tip we illustrated how Get-Date can take a format string and convert DateTime values to strings. The string conversion always uses...

Translating VBScript to PowerShell

Most old VBS scripts can be easily translated to PowerShell. The key command in VBS is “CreateObject” which lets you access system libraries....

Detecting WinPE

PowerShell can run inside WinPE environments. If you’d like to detect whether your PowerShell script runs inside a WinPE environment, you can...

Running CMD commands in PowerShell

PowerShell by default does not support the native cmd.exe command such as „dir“. Instead, it uses historic aliases called...

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

Reading Event Logs Smart (Part 1)

When you query an event log with PowerShell, by default you get back a text message with the logged information. For example, if you’d like to know...

Turning Display Off Immediately

If you are about to launch a lengthy automation script, why not turn off the display right away instead of waiting for the screen saver timeout to...

Using Chocolatey with PowerShell

Chocolatey is a free package manager for Windows that can be used to download and install software. Before you can use Chocolatey from PowerShell,...

Sort IPv4 and IPv6 Addresses Correctly

When you try and sort IPv4 addresses via Sort-Object, this fails: PS> '10.1.2.3', '2.3.4.5', '1.2.3.4' | Sort-Object 1.2.3.4 10.1.2.3 2.3.4.5...