In Windows Vista/Server 2008, Microsoft introduced many new service and application specific log files. PowerShell can access those with...
database-tools
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...
Kill Specific Excel Instances (or other programs)
Stop-Process can very easily kill all instances of Excel or another program. So this line will kill all instances of Excel: Stop-Process excel...
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...
Use Hash Tables To Convert Numeric Return Values
You can use Hash Tables to translate individual return values to clear text. This example shows you how to convert return codes 0 and 5 to some...
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...
Filter PowerShell Results Fast and Text-Based
Take a look at this simple filter called grep: filter grep($keyword) { if ( ($_ | Out-String) -like "*$keyword*") { $_ } } And here are...
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...
Changing Service Start Mode the PowerShell Way
When you list services with Get-Service, you will find that a lot of properties may seem to be missing. You can still set such properties when you...
Changing Service Startmode
You can use WMI like this if you want to change a service start mode:...