Powershell

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

Sort IPv4 Addresses Correctly

In the previous tip we published a super-fast function called Test-OnlineFast, and this function was able to ping an entire IP segment in record...

Final Super-Fast Ping Command

In the previous tip series, we developed a new function called Test-OnlineFast that can ping multiple computers in record time. For some reason, the...

Select-Object and -ExcludeProperty

Here is a line of code that often puzzles PowerShell users: Get-Service | Select-Object -ExcludeProperty Name When you use Select-Object, its...

Converting PowerShell to Batch

Here is a fun PowerShell function called Convert-PowerShellToBatch. Provide it with the path to a PowerShell script, or pipe in the results from...

Converting User Name to SID

If you’d need to find out the SID for a user name, here is a useful chunk of code that does the job: $domain = 'MyDomain' $username =...

Getting Cached Credentials

In the previous tip we talked about a public module called PSCredentialManager that helps you manage cached credentials. Sometime, less is more, so...

Parsing Distinguished Names

Distinguished names are strings, and strings contain powerful ways of parsing data. The most powerful yet simple approach is the Split() method....

Creating Random MAC Addresses

If you just need a bunch of randomly generated MAC addresses, and you don’t care much about whether these addresses are actually valid, then...