What if you would like to get a quick overview of all error events in any event log. Get-EventLog can only query one event log at a time. So, you...
database-tools
Creating IP segment lists
If you need a list of consecutive IP addresses, you can check out this function. You can see that it takes a start and an end address and then...
Getting significant bytes
If you need to split a decimal into bytes, you can use a function called ConvertTo-HighLow, which uses a clever combination of type casts to...
Test Internet connection
Try this line if you would like to know whether a machine is currently connected to the Internet:...
Making sure PowerShell scripts run in 32-bit
If you are using code that can only run in a 32-bit environment (i.e. using old database drivers or COM objects), here is a solution that will...
Running PowerShell on 64-bit systems
On 64-bit systems, PowerShell will by default run in a 64-bit process. This can cause problems with snap-ins, some COM-objects (like...
Splitting hex dumps
Imagine you have a text string with a hex dump so that each hex number consists of two characters. How would you split this into individual hex...
Finding new processes
Get-Process will return a list of all processes. If you just want to see those started within the last 10 minutes, you can check StartTime. Both...
Load registry user hive
If you need to manipulate registry data from another user, you may be out of luck because HKEY_CURRENT_USER always points to your own user data....
Dump enumerations
You can create a simple helper function called Get-Enum to list all the values in an enumeration: function Get-Enum($name){...
Compare services on two computers
Ever wondered why one computer runs well and another does not? Here is an example of how you can compare service configuration on two machines as...
Use Foreach-Object instead of Select-Object -expandProperty
As you may know, Select-Object can return the content of an object property when you use the parameter -expandProperty. This will get you a list of...
Appending text files without new line
You can use Out-File with -Append to append lines to a text file, but there is no way to add text information without a line break. To do that, you...
Creating random passwords
Take a look how easy it is for PowerShell to create random passwords: PS > $list = [Char[]]'abcdefgABCDEFG0123456&%$' PS > -join...
Escaping text in regular expressions (RegEx) patterns
Some PowerShell operators, such as –match, expect regular expressions. If you just want to match plain text, you will need to escape any...
Formatting multiple text lines
Use the awesome formatting operator -f to insert dynamic information into text! You can store the formatting information in a variable and use it in...
Creating new GUIDs in various formats
You can easily create new GUIDs (Globally Unique Identifiers) using the GUID type and its NewGUID() method. But did you know that you can use a...
Read text files that are in use
Get-Content can read text files only line-by-line. Use .NET directly if you need the exact content of a text file as one large text. Here is how you...
Enumerate Device Services
You will find that Get-Service will not list device services. Here is how you can enumerate those low-level services:...
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...