Friday Fun: A SysInternals PowerShell Workflow

Over the years I’ve come up with a number of PowerShell tools to download the SysInternals tools to my desktop. And yes, I know that with PowerShell 5 and PowerShellGet I could download and install a SysInternals package. But that assumes the package is current.  But that’s not really the point. Instead I want to use today’s Friday Fun to offer you an example of using a workflow as a scripting tool. In this case, the goal is to download the SysInternals files from the Internet.

First, you’ll need to get a copy of the workflow from GitHub.

A workflow command is like a function, in that you need to load it into your PowerShell session such as dot sourcing the file.

. c:\scripts\Update-SysinternalsWorkflow.ps1

This will give you a new command.


The workflow can now be executed like any other command.


The workflow’s main advantage is that it can process items in parallel and you can throttle the activity. In my workflow, I am processing 8 files at once.

One thing to be careful of in a workflow is scope.  You shouldn’t assume that variables can be accessed across the entire workflow. That’s why I am specifically scoping some variables so that they will persist across sequences.

I really hope that one day the parallel processing will make its way into the language because frankly, that is the only reason I am using a workflow. And it’s quick. I downloaded the entire directory in little over a minute on my FiOS connection. The workflow will also only download files that are either newer online or not in the specified directory.

If you are looking to learn more about workflows, there is material in PowerShell in Depth.

I hope you find this useful. Consider it my Valentine to you.

Getting Local User Accounts the PowerShell Way

It seems I’m always seeing requests and problems on getting local user accounts using PowerShell.  However, even though we are at PowerShell 5.0,  Microsoft has never released a set of cmdlets for managing local user accounts. So many of us have resorted to creating our own tools. I now have my latest iteration of a function to get local user account information from remote computers.

The function takes a shortcut of sorts by using the ADSI type accelerator to connect to a remote computer. This is the same technique we used back in the VBScript days. However, this technique isn’t conducive to alternate credentials and requires legacy protocols like RPC and DCOM.  But that isn’t necessarily an issue as I’ll show you in a few minutes.

The function connects to the remote computer and then uses some COM object voodoo, to enumerate local account information. By default, the command will list all user accounts.


Or you can specify a single user account name.


The function accepts pipeline input making it easy to check multiple servers at once.


On important note: if you query a domain controller you will get domain accounts.

Remember I mentioned this command uses legacy protocols. One alternative is to use PowerShell remoting and Invoke-Command. First, create the necessary PSSessions, using alternate credentials if necessary.

Then get the function’s scriptblock.

Now you can use this with Invoke-Command:


Or query for a specify account:


You can find the complete script, which includes an alias on Github.

I hope you’ll let me know what you think and that you find this a useful addition to your PowerShell toolbox. If you run into problems, please post them on the Gist page.

More Power is on the way

P50For the past several months, I’ve been debating about what to do for the next iteration of my Hyper-V network.  I rely on it heavily for my writing, course-ware development, and training.  For awhile now I’ve been traveling with a Yoga 2 Pro which runs a few virtual machines, and a Gigabyte Brix unit with 16GB of RAM and an i7 CPU for everything else.  Because of the two units I also tend to travel with a small 4 port switch plus all the necessary power  supplies and cabling. Even though the Yoga 2 is really light, by the time I pack everything up, as they say, “not so much.”

I also have realized that there are a few more virtual machines I’d like to add to my running network which meant I needed to expand my Hyper-V setup. I was torn between building a mini-ITX solution with this motherboard which could have supported up to 128GB of RAM. I thought that if I needed to travel with it, a mini-ITX wouldn’t be that much of a burden.

Or, I could stick with a laptop. I knew that Lenovo was coming out with a new line of ThinkPad workstations.  So I kept waiting. And waiting. The ThinkPad P50 and the ThinkPad P70 promised to be beasts. At least the specs I wanted. For my purposes, what was most tantalizing was the ability to get a Xeon CPU in a laptop that would support up to 64GB of RAM. Yeah, the unit would be a bit bigger than what I had now at 5.6 lbs but if I maxed out the memory (and why wouldn’t you!), I would only have to deal with a single item at conferences and classes. So I did.

I put in an order for a P50 (the P70 is a 17″ version which was bigger than I really needed).  Even though Lenovo, like most vendors, offers plenty of upgrades, I opted to keep this unit as base as possible. I did get the Xeon CPU and upgraded to Windows 10 Pro (even though I eventually plan to run Windows Server 2016 on it). I also opted for a 2 year warranty with accidental damage  to hedge my bets. Not that I’m expecting any issues but I travel and things happen.  I decided to do my own memory and drive upgrades so save a little money. Right now I’ve invested about $2100 including tax.  I think the memory will be about another $400.  I have a spare drive I’m hoping will work in the P50.

My plan is to set it up as a Hyper-V server in my test domain. When I need to go to a conference, I’ll replicate the VMs I need and go.  The schedule is tight, but I’m hoping to bring it with me to Techmentor so if you will be in Las Vegas and want a P50 tour, be sure to find me.  If nothing else, it should be joining me at the PowerShell Summit.

I’ll be posting pictures, impressions and notes on upgrades as they happen. Much more to come.

Advice, solutions, tips and more for the lonely Windows administrator with too much to do and not enough time.