database-tools

Using the OpenFile Dialog

PowerShell 3.0 and newer Here’s a quick function that works both in the ISE editor and the PowerShell console in PowerShell 3.0 and above):...

Use Group-Object to Create Hash Tables

All PowerShell versions Group-Object can pile objects up, putting objects with the same property together in one pile. This can be quite useful,...

Have PowerShell Cheer You Up!

All PowerShell versions Writing PowerShell code is fun but can be frustrating at times. Here’s a function that makes PowerShell cheer you up....

Logging What a Script Does

All PowerShell versions You probably know that in a PowerShell console (not the ISE editor), you can turn on logging: PS> Start-Transcript This...

A Fun Beeping Prompt

All PowerShell versions If your computer has a sound card, here is a code snippet that will drive your colleagues nuts: function prompt { 1..3 |...

Returning More Than One Value

All PowerShell versions If a PowerShell function needs to return more than one value, best practice is to return objects, and store the information...

Edit Network “hosts” File

All PowerShell versions If you find yourself editing the “hosts” file regularly, then it may be tedious to manually open the file in an...

Watch Out With UNC Paths!

All PowerShell versions Many cmdlets can deal with UNC paths, but using UNC paths can produce flaky scripts. Take a look at this: PS> Test-Path...

Finding AD Users

All PowerShell versions Searching the AD can be done with simple calls provided you are logged on an Active Directory domain. In a previous tip we...

Finding and Dumping Registry Key Paths

All PowerShell versions In a previous tip we illustrated how to convert an internal PowerShell path format to a real path. Here is a use case. This...

Correcting PowerShell Paths

All PowerShell versions Occasionally, you might stumble across strange path formats like this one:...

Case-Correct Name Lists

All PowerShell versions Let’s assume it’s your job to update a list of names. Here is an approach that will make sure that only first letter in a...

Hibernate System

All PowerShell versions Here is a simple system call that will hibernate a system (provided of course that hibernation is enabled): function...

Recursing a Given Depth

PowerShell 3.0 and newer When you use Get-ChildItem to list folder content, you can add the –Recurse parameter to dive into all subfolders....

Managing Printers Low-Level

All PowerShell versions Recent Windows operating systems like Windows 8 and Server 2012 come with great printing support, but if you run older...

Aliases Can Be Dangerous

All PowerShell versions Aliases enjoy the highest priority among executable commands in PowerShell, so if you have ambiguous commands, PowerShell...

Converting Special Characters, Part 2

All PowerShell versions In a previous tip we illustrated how you can replace special characters in a text. Here is another approach that may be a...

Converting Special Characters, Part 1

All PowerShell versions Sometimes it becomes necessary to replace special characters with other characters. Here is a simple function that does the...

Test-Driving Scripts without Aliases

All PowerShell versions Aliases can be cool in interactive PowerShell but should not be used in scripts. In scripts, use the underlying commands (so...

Delete Aliases

All PowerShell versions While you can easily create new aliases with New-Alias or Set-Alias, there is no cmdlet to delete aliases. PS> Set-Alias...

Finding AD Accounts Easily

All PowerShell versions You do not necessarily need additional cmdlets to search for user accounts or computers in your Active Directory. Provided...

Loading Functions from Separate File

PowerShell 3.0 and newer To keep things simple, you may want to put PowerShell functions into a separate file. To load these functions into your job...

Creating Great Reports

All PowerShell versions You can change all properties of objects when you clone them. Cloning objects can be done to “detach” the object...

Accepting Multiple Input

All PowerShell versions When you create PowerShell functions, here is a template that defines a InputObject parameter that will accept multiple...