PowerShell remoting: variations on a theme

Github.

Advertisements

Beyond Compare: command line comparison

Say I have a bunch of folders thus…

, and I want to compare them from the command line to start with, with the aim of eventually passing say the folder paths as parameter.

This would/could be the caller. Note that I have put the bcomp.exe executable in a local folder for convenience for now. It seems to have no other dependencies, other than a valid or trial license:

 

And this is the instructions/script file.

At runtime that yields this, with the only frustration that the folder icons are not drillable, and do not bring out the fact that there are differences between their children of the same name.

bc04

Gist

 

PowerShell: Get-RandomString

I’ve seen plenty of long-winded ways of getting a random string (not int) in PowerShell, but none of them seem to mention the obvious of taking a GUID, stripping of the dashes, and returning the required size. Obviously that restricts you a bit, but for my purposes, it is fine.

This is all there is to it:

function Get-RandomString ([int] $stringSize) {
    $randomString = [System.Guid]::NewGuid() -replace '-',''
    ([string] $randomString).Remove($stringSize)
}

And you call it thus…

    Get-RandomString 6

And get returned something like this:

Get-RandomString01

Here’s another way, starting off with the 1 liner, and the breaking it down a bit:

Get-RandomString02

 $randomString = ([char[]]([char]'a'..[char]'z') + 0..9 | Sort-Object {Get-Random})[0 .. 8] -join ''