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…)
Month: October 2014
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…)
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…)
Compare-DataTable
Have you ever been in a situation where you needed to compare two DataTables? No? Well, if you ever do, I have your back! This function will take two DataTables and compare them, either only schema or a full compare.
(more…)
Get-FolderSize
This is a little function I wrote one day when I needed to get the total size of a set of folders (including sub folders). It performs a recursive search and computes the total count and also shows the size in a more human-readable format. It also have a “hidden” property called SizeInBytes that can be helpful if you want to do size calculations and need the size in a common format.
(more…)
New-DataTable
I have written previously about how to convert an object to a DataTable and how to create one based on an existing MSSQL table, but now I will share a function to create a new empty DataTable. Sure, this isn’t very complicated to do manually, but using this function you can define the table structure using an ordered dictionary, which makes it much easier to update later if needed.
(more…)
Get-VMWareSnapshot
Ok, I understand this one is done “to death” already, but anyway, here is my take on it. I had a need for something a bit more optimized than the Get-Snapshot command, so I had to use Get-View. I also needed the possibility of either getting all snapshots, or filter on VM name.
(more…)
Reordering columns in a DataTable
If you need the columns in a DataTable in a specific order, you just create them in the order you need, right? But what if you are dealing with a DataTable full of data?
(more…)