database-tools

Find Latest Processes

You should try this piece of code to find all processes that were started within the past 10 minutes: Get-Process | Where-Object { try {...

Check for Wildcards

If you need to test for wildcards, you should try this .NET method: $path = "c:\test\*"...

Use Multiple Wildcards

Did you know that you can use multiple wildcards in paths? This will give you a lot of control. Check this out: This line will find all DLL-files in...

Open Many Files With One Command

To quickly open all files of a kind, such as all text or script files found in a folder, you should try the  Open-File function. It will accept...

Filter by More Than One Criteria

You should probably use Get-Childitem with its -filter parameter to list specific files because it is much faster than -include. This line will...

Finding Software Updates

In Windows Vista/Server 2008, Microsoft introduced many new service and application specific log files. PowerShell can access those with...

Search for Keywords in Help Files

You may be surprised that you cannot filter Help texts by keywords: Get-Help Dir | Select-String "File" This will not return...

Encrypt Files With EFS

You should first access the file using Get-Item to encrypt a file with EFS: $file = Get-Item c:\somefile.txt Next, call its Encrypt() method....

Split Special Characters

PowerShell’s new –split operator can split text into parts. Usually, you will submit a delimiter character to tell –split where to...

Learn About Operators

Operators are an important part of the PowerShell language. Try this to learn more about them: Help operators This will list all the different kinds...

Use Sort-Object With Better DataTypes

This line of code will sort system DLLs based on file version. However, it turns out that it sorts incorrectly: dir $env:windir\system32 -filter...

Output Data in Color

When you pipe results to Write-Host to output them in color, you may be in for a surprise: Get-Process | Write-Host -ForegroundColor Yellow The...

Resolve IP-Addresses

This one-liner accepts one or more IP-addresses and will try to resolve the address. If DNS returns valid information, you will receive the host...

Be Careful With Strict-Mode!

You will discover that PowerShell is production-oriented. So, if you specify object properties that do not exist, you will simply get back...

Find True Property Names

Sometimes, the column names you see when you run cmdlets do not really correspond with the true object property names. For example, Get-Process will...

Wait For a Program to Finish

You should use Start-Process and its -Wait parameter if you want to force PowerShell to wait for a program to finish before it continues:...

Analyzing Windows Launch Time

Beginning with Windows Vista/Server 2008, you can get rich information about your machine from the new additional application and service logs that...

Use Where-Object to Filter Results

You can always use Where-Object when you need to filter results. This cmdlet expects a filter script to determine the results you want. Here are...

Getting AD Terminal Server Settings

On client operating systems, such as Windows 7, there are some Support libraries missing that you will need  to display terminal server...

List Registry Hives

Use the provider name instead of a drive name when you need to get a list of all registry hives:   Dir Registry::   ReTweet this Tip!

Writing Registry Key Default Value

If you need to set the default value for a registry key, you can  use either of these approaches:   Set-ItemProperty -Path...

Dumping Help

You can start by dumping all Help information into a file to learn more about a PowerShell cmdlet. You can then read all details about the cmdlet...

Out-GridView Requirements

Out-GridView is a great way to present results in a “mini-Excel” sheet: Get-Process | Out-GridView However, Out-GridView has two...

Use CTRL+Arrow!

Inside the PowerShell console, you can hold CTRL while pressing the arrow key to move the cursor word-by-word. This way, you can move the cursor...

Determining Service Start Mode

By using WMI, you can enumerate the start mode that you want your services to use. To get a list of all services, try this: Get-WMIObject...