This one should appeal to both the statistically inclined of you, as well as those interested in cryptography. Measure-Frequency will take any array (or string) and give you the frequency distribution of it’s contents. (more…)
Category: PowerShell
Show-BinaryFile – A hex viewer in PowerShell
In my previous post I showed you a couple of wrapper functions I made to handle binary to string conversion (and vice versa). Building on one of these I thought it would be fun to try to make a simple file hex viewer, similar to how popular hex editors work (without the editing part of course). (more…)
Binary/String conversion using Win32 API
I recently came across the Matasano Crypto Challenges, which is a set of challenges you can go through to learn more about cryptography.
While looking around for tips online for the first challenge, I stumbled upon an excellent blog article by Vadims Podāns, where he shows how, by using the Win32 native functions CryptStringToBinary and CryptBinaryToString, you can easily convert between binary and string in PowerShell. (more…)
C# vs PowerShell Operators
Being able to read C# is a huge plus when doing advanced scripting, if for no other reason than most examples in the .NET documentation are given as C# (or Visual Basic). Luckily for us, understanding C# isn’t that hard when you have worked with PowerShell a while. But one of the areas where they can differ a bit are the operators. I have created this Cheat Sheet as a tool to be able to quickly translate between C# operators and the PowerShell equivalent. (more…)
Quick tip: Get supported DateTime formats
When using the Format parameter of the Get-Date cmdlet, if you ever need a list of all supported format patterns, use this one-liner:
(more…)
Quick tip: Trim null-terminated strings
Recently, when reading string data from a binary file, I stumbled across the “problem” of trimming the terminating character from a null-terminated string. I started getting all creative about it, but it soon became quite a mess (code-wise), so I that down and had a re-think. This is how I ultimately ended up doing it. (more…)
Quick tip: Fix those line endings
In dealing with data transferred between different operating systems, we often come across the irritating phenomenon of, what might appear as, a file without any spaces in them. This is of course because of different end of line (EOL) characters, and I’m going to show you a quick and easy way of using PowerShell to “fix” these for Windows. (more…)
Invoke-WinMerge
Doing file compares can be quite confusing using Compare-Object, so unless you only want to check for equality, using a GUI can be tremendously helpful. Enter WinMerge. I guess most of you have used, or are currently using, this fabulous tool. I created a simple wrapper for WinMerge so that it’s easier than ever to open file (or folder) comparison right from the PowerShell console. (more…)
View Steam wishlists with PowerShell
With Steam having frequent sales, I find I often pop into my own, as well as my friends wishlists to plan purchases. Wouldn’t it be great to be able to list a wishlist from the PowerShell console? (more…)
Get-RootMeanSquare
Ever needed to get the Root Mean Square of a set before? Me neither, but I went ahead and created a small function for it anyway. (more…)