A PowerShell implementation of Touch

Touch is a well known command in the Unix/Linux world. It is used to update the time stamp of files, and additionally will create a new empty file if it doesn’t exist already (unless you use the -c parameter, which will suppress this behaviour).

Invoke-Touch is a PowerShell implementation of Touch, and supports all the functionality of the original command. I have added the Unix/Linux parameter names as aliases, so if you are familiar with touch, you shouldn’t have any problems using this function.
(more…)

Resolve-PathEx

Resolve-PathEx is a wrapper around Resolve-Path that adds support for resolving paths for files that don’t exist. Why would you ever want that? Have you ever created a function with a path parameter and a file name parameter, where the function itself would create a new file? With this function you could combine those two parameters into one. The great thing about Resolve-PathEx is that it supports wildcards (the same as Resolve-Path).
(more…)

Add-FormatTable

I was working at a script where I created a custom object, and I wanted to to change the default properties shown when the object where written to the host. Easy enough, right? I have done this before of course, but this time I started thinking if it were possible to have the headings be different when using the default view, as opposed to, let’s say when shown using Format-List.
(more…)

Get-Mockaroo

UPDATE: The function now also supports creating dynamic data sets!

Have you ever been in a situation where you wish you had some random data lying around while testing some code or whatnot? I do all the time. What I usually do is hunt around my disk after some random csv that I can use. Then someone on Twitter posted about an online random generator called Mockaroo. And guess what, it has an API.
(more…)

Measure-ScriptBlock

I recently came over an interesting thread on LinkedIn where they talked about how to count lines in a CSV. A lot of good code examples where posted, where they tried to optimize for speed and memory consumption. I decided to try out some ideas of my own, but as I often do, I got sidetracked into building a function to easily perform measurements of code blocks instead.
(more…)