database-tools

Ping and Range Ping

In PowerShell, you can access .NET methods directly so it is easy to add a ping functionality: $object = New-Object...

Validating User Input

When writing a function that accepts parameters, you can strongly-type parameters so that an exception occurs when the user submits the wrong...

Generate a New GUID

GUIDs are "Globally Unique Identifiers," which are so random that you can safely assume they are unique worldwide. GUIDs are used whenever...

Discover about-Topics

PowerShell comes with a lot of documentation. It is just sometimes hard to find. For example, to get a list of all available operators, do this:...

Assigning Multiple Variables

In PowerShell, you can initialize multiple variables in just one line. The following line sets all variables to the value 1: $a = $b = $c = $d = 1...

Automatic Aliases

All Get-Cmdlets (cmdlets that start with "Get") have an automatic type accelerator. You can use those cmdlets without the verb. So...

Exploring Privileges

On Vista with UAC enabled, you are not Admin by default. It might be interesting to find out if PowerShell currently has Admin privileges enabled....

Enumerating Drive Letters

Sometimes, you may want to find the next available drive letter for a network drive or enumerate drive letters for other purposes. An easy way to...

Finding (and Deleting) Duplicate Files

There are numerous ways of finding duplicate files. One approach uses Group-Object and groups your files by LastWriteTime and Length, assuming files...

Counting Items in a Folder

Get-Childitem returns all files in a folder. PowerShell returns an array if there are at least two items in a folder. To force PowerShell to always...