Eric's Technical Outlet

Learning the hard way so you don't have to

Convert Visual Basic Form to PowerShell

Last Updated: v1.05, May 22, 2015

From time to time, I like to have my PowerShell scripts display a nice GUI. Often, I have a scheduled script with numerous configuration options, and I see no value in forcing any person who uses my scheduled script to have to decipher and retool the options when I can slap together a UI that builds the configuration file for them. That’s just one example of why you might want to have PowerShell generate a GUI. But, this post is not about the philosophy of using a GUI in PowerShell, or using PowerShell instead of a full application development environment. This is about the mechanics.

Read more of this post

Advertisements

PowerShell: Script that Calls Itself Recursively

To have a PowerShell script that calls itself recursively, use the following construct:

Invoke-Expression -Command $PSCommandPath

If the script uses parameters, use the following construct:

Invoke-Expression -Command ($PSCommandPath + ' -Parameter1 FixedValue -Parameter2 $VariableValue')

If you want to call the script exactly as it was initially called (be careful!):

Invoke-Expression -Command $PSCmdlet.MyInvocation.Line

Read more of this post

PowerShell: Sort a Windows Forms ListView without a Custom Comparer

I realize that PowerShell is mainly for command-line operations and scripting, but I’ve found more than a few uses to have it present a GUI. From my own portfolio, CoreFig would be a prime example. What GUIs are especially good for is presentation, selection, and manipulation of complex data structures. One control that’s suited for such uses is the ListView. Using a ListView in PowerShell isn’t more difficult than using most any other Windows Forms object. Sorting it, on the other hand, isn’t simple. Most of the solutions I found did not work at all, only did a sort-of sort, or did some complicated work with the .Net Framework. I have concocted a solution that stays in PowerShell.

Read more of this post

My Hyper-V Cluster Book is Published

I have written a book dedicated to Hyper-V 2012 and 2012 R2 in a cluster configuration. Read more of this post

10GbE is Certainly in Your Future, But Must It Be In Your Present?

It’s interesting to watch how people will become accustomed to a certain standard to the point that they have difficulty imagining any other standard. One fairly recent trend in some computing circles is the insistence that all new server systems come installed with 10GbE adapters by default. While their positions have merit, it’s not a good rule… yet.

Read more of this post

No, I Will Not Be Your Friend

It’s not personal. In fact, that’s the point. But, it’s not exactly true, either. You’re going to have to click “Read More” to get the explanation for that.

Read more of this post

This Space is Not For Sale

It’s always been an unofficial policy of mine anyway, but now I’m stating it outright. I cannot accept offers to partner for advertisement purposes.

Read more of this post

Defrag (Is) For Dummies

Kind of funny how one little word really changes the meaning of a sentence, doesn’t it? The title is a bit harsh but there is more than a little truth in it.

Read more of this post

Explaining the Hyper-V Virtual Switch

I’ve been lurking in a few Hyper-V forums over the past few weeks, and I’ve noticed that people really have a hard time understanding the Hyper-V virtual switch. Even worse, a lot of the “experts” valiantly trying to help them out don’t seem to really get it either. A lot of them do get it, but have a hard time trying to explain it. So, I put together a two-part series where I try my hand at explaining the basics of this technology. You can find it on the Altaro site.

How Android 4.2 and Firefox 19 Made Me Miss Microsoft

During the last couple of presidential cycles, the opposing candidate did a better job of getting me to vote against him than his rival did. The latest versions of Android on my phone and Firefox on my desktop are doing the same thing. Here I am, with papers to write for University, a major project to produce work for, and I need to get it all done in time to get some decent sleep because I need to be well-rested for my day job. But my normal tools of choice are holding me back. The bad thing is that they’re the ones that were supposed to save us from the bloated, unstable, user-unfriendly competition. The saviors have become the monsters.

Read more of this post