ps1

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 “dir” to point you to the...

Progress Bar Timer

Use the PowerShell progress Bar Here is a simple example using the PowerShell progress bar. The code displays a progress bar counting down a break....

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. Installing Chocolatey via PowerShell Before you...

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

Reviewing the Test-OnlineFast Function In the previous tip we published a super-fast function called Test-OnlineFast, and this function was able to...

Final Super-Fast Ping Command

Revisiting the Test-Online Fast Function In the previous tip series, we developed a new function called Test-OnlineFast that can ping multiple...

Select-Object and -ExcludeProperty

Here is a line of code that often puzzles PowerShell users: Get-Service | Select-Object -ExcludeProperty Name Understanding the -ExcludeProperty...

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 =…

Getting Cached Credentials

Managing Cached Credentials with PSCredentialManager In the previous tip we talked about a public module called PSCredentialManager that helps you...

Parsing Distinguished Names

Using Split() for Parsing Distinguished Names Distinguished names are strings, and strings contain powerful ways of parsing data. The most powerful...

Creating Random MAC Addresses

Randomly Generated MAC addresses If you just need a bunch of randomly generated MAC addresses, and you don’t care much about whether these addresses...

Converting Binary String to Integer

Convert a binary text string into integer Here is how you convert a binary text string into the corresponding integer value: $binary = "110110110"...

Turning AD User into a Hash Table

Sometimes it could be useful to load all attributes from a given AD user into a hash table. This way, you could edit them, and then use Set-ADUser...

Exporting ActiveDirectory Module

To manage users and computers in your Active Directory from PowerShell, you need the ActiveDirectory module which comes as part of the free RSAT...

Working with LDAP and Dates

LDAP filters LDAP filters are a fast and powerful way of retrieving information from Active Directory. However, LDAP filters use a very low-level...