Powershell

Lowering Process Priority

Sometimes, you may want to lower process priority for some processes. That's a PowerShell one liner. Note that the next line lowers priority for...

read more

Calling ChkDsk via WMI

Some WMI classes contain methods that you can call to invoke some action. For example, the next line initiates a disk check on drive D:...

read more

Rename Drive Label

WMI can also read any drive label (the name that appears next to a drive inside Explorer), and you can change the drive label, too—provided...

read more

Remove Empty Entries

One little known fact is that Where-Object is a cool and simple way of removing empty objects. Let's say you want to list all network adapters...

read more

Use PowerShell Cmdlets!

Whenever possible, try to avoid raw .NET access if you would like to create more readable code. For example, the following line returns the current...

read more

Secret Timespan Shortcuts

Usually, to create time spans, you will use New-Timespan. However, you can also use a more developer-centric approach by converting a number to a...

read more

Adding and Subtracting Time

There are actually two different ways of manipulating dates and times. Here is the high-level approach to subtract 30 days from today: (Get-Date) -...

read more

Creating Time Spans

A time span represents a time interval, and you can use time spans to subtract or add time to a date. For example, to get the date seven days ago:...

read more

Add Help to Your Functions

You should simply copy and paste the following block comment right above your functions and magically Get-Help works with your functions, too!...

read more