posts-powershell

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

Converting Numbers

The .NET convert class is a great help when you need to convert numbers between different systems. Here's how you can convert a decimal into a...

Outputting HTML Reports

PowerShell can export results as HTML. Simply pipe the results to ConvertTo-HTML and save the result in a file. When you do that, it is wise to use...

Add Custom Properties

While objects contain a wealth of information, this information sometimes isn't in the right format. Let's take WMI objects representing...