ps1

Analyzing Event Logs

Event logs are a great source of information. The only problem is that they tend to be overwhelming. Try using WMI and the Win32_NTLogEvent class to...

read more

Reading Text Files

Reading text files is easy using the Get-Content cmdlet: $text = Get-Content $env:windirwindowsupdate.log However, Get-Content reads the file line...

read more

Sorting Text Files

You need to sort a text file, maybe a list of servers or names? Here is how: $file = $homeserverlist.txtGet-Content $file | Sort-Object |...

read more

Finding Folder Changes

Compare-Object can help you monitor folder content and find changes. To monitor, first create an initial snapshot. At a later time, you can then...

read more

Comparing Results

PowerShell makes it easy to compare results and find only things that changed. For example, you may want to list only processes that started after a...

read more

Write-Protected Arrays

Arrays are by default read/write so you cannot lock down arrays and make them read-only. To create a read-only array, you can "upgrade" it...

read more

Turbo-Charging Arrays

Simple arrays have no built-in mechanism to insert new elements or extract elements at given positions. For example, to extract the 5. element from...

read more

Creating Numeric Ranges

There is a clever trick in PowerShell to create numeric ranges that you probably know: 1..10 But did you know you can use variables with this trick?...

read more

Creating Random Numbers

Ever wanted to create an electronic dice (or needed random numbers for other purposes)? With PowerShell, simply instantiate a Random object and call...

read more