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…)
Category: PowerShell
Quick tip: Validate IP address parameter in custom functions
This is a quick tip for the situations where you are building a function with an IP address parameter. There are many ways of validating that a valid IP address are filled out, but this is by far the easiest.
(more…)
Grep, the PowerShell way
I recently ran across an article about ‘15 Practical Grep Command Examples In Linux/Unix‘, and thought it would be cool to run through each of the examples, and give the PowerShell equivalent for each one.
(more…)
PowerShell and the clipboard
Here are two small clipboard functions for PowerShell. Get-ClipboardText gets the current text in the clipboard while Out-ClipboardText will send text to the clipboard.
(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…)
More PowerShell
This is a small function that emulates the behaviour of the old DOS command ‘more’. The only caveat is that it doesn’t work when running under ISE.
(more…)
Trace-Route
For some reason I wanted to write a trace route script in PowerShell, but decided to run it through Google first to see if it had been done. Surprisingly few results came up, and as far as I can tell, only one true PowerShell script doing Trace Route without just being a wrapper for tracert or something similar: https://snoj.us/75/traceroute-with-starting-ttls/
(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…)
Get-TrimmedMean
I recently published my Measure-ScriptBlock function, where you can set how many times you want to take measurements of your code block, and get the mean value (average) calculated before output. That is all and well, but running it I could see that sometimes there would be some measurements that would spike and make the mean value higher than it really “should” be.
(more…)
Get-SpecialFolder
This is a small function that will get Windows special folders and their paths. You can search by using the name parameter.
(more…)