powertips

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

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 are a fast and powerful way of retrieving information from Active Directory. However, LDAP filters use a very low-level date and time...

Show or Hide Windows

PowerShell can call internal Windows API functions, and in this example, we’d like to show how you can change the show state of an application...

Modern Replacement for systeminfo.exe

For ages, systeminfo.exe returned all profiling information for a computer, and could made object-oriented in Powershell – somewhat: PS...

Finding AD User by SAMAccountName

PowerShell 5 The free Microsoft RSAT tools come with a full-blown ActiveDirectory module, but sometimes simple AD tasks can be mastered with just a...

Cleaning Week: Deleting CBS Log File

Windows maintains a log file named cbs.log in $env:windir\logs\cbs. It logs various pieces of information related to the Windows trusted installer,...

Adding New Nodes to an XML Document

If you need to add new items to an XML document that already contains such items, the easiest way is to search for an existing item, then clone it....

Bringing Window in the Foreground

PowerShell can use Add-Type to access internal Windows API functions. This way, it is easy to bring any process window into the foreground. Here is...