Extending PowerShell with Custom Property Sets

If you’ve been following along on the blog recently you’ve read about my use of PowerShell type extensions. This is a way of adding new properties to things I use all the time. The goal is to save typing and get what I need with minimal effort. You can also take this a step further by creating your own property sets.

Continue reading

Extending Hyper-V with PowerShell

Lately I’ve been writing about my use of PowerShell type extensions as a way to get more done quickly. Or at least give me the information I want with minimal effort. I use Hyper-V a great deal and the Hyper-V cmdlets are invaluable. And while a command like Get-VM provides a lot of information, I always seem to want more so I thought I’d share with you my Hyper-V related type extensions. Even if you don’t need or use Hyper-V, you might find my techniques useful.

Continue reading

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.

Adding Some Power to Hyper-V VM Notes

Since I work at home, I rely a great deal on my Hyper-V environment. I’m assuming if you are using Hyper-V at work the same is true for you.  Because I do a lot of testing, it is difficult sometimes to remember what is running on a given VM. Did I update that box to PowerShell v5? Is that VM running Windows Server 2016 TP 3 or TP4?

Hyper-V virtual machines have a setting where you can keep notes which seems like the ideal place to store system information.  Since most of my Windows machines are on my public network and the virtual machine name is the same as the computer name, I can easily use PowerShell remoting to connect to each virtual machine, get some system information, and update the corresponding note.

I can run a command like this to get the system information I need.

I get back a result like this:

System Information

system information

In my code, I want to include the computer name just in case it is different. If the server has the Resolve-DNSName cmdlet, I invoke it otherwise I use the .NET Framework to resolve the name.

To set the the Notes property , I can use Set-VM.

Be aware that this behavior will replace any existing notes. In my final code, I take that into account and by default I append the system information. But there is a parameter to replace the note contents if you wish.

My final code also includes a parameter to use the VM’s IP address instead of it’s name. I have a few VMs that are not part of my test domain, but I register their names in my DNS.

Here’s the complete script.

Note that this is a script and not a function.  I can now easily update my virtual machines.

setting VM note

getting system information for the VM note

And here’s the result:

viewing the note

The new note

Of course you can modify the script to include any information you want in the note.

If you find this useful I hope you’ll let me know.



I have updated the script and turned it into a function. You can now pipe virtual machines into the function. I also included a Passthru parameter so you can see the Note information. The function is hosted on GitHub at https://gist.github.com/jdhitsolutions/6f17c1d901ff870ff7a3.

What Are You?

Here’s a quick way to tell whether a given machine is real or not: check the Win32_Baseboard class. You can use either Get-WmiObject or Get-CimInstance. Notice the results from a few physical machines.

Now see the result when querying a Hyper-V virtual machine:

I don’t have any VMware available so I don’t know what kind of result that would show. I also haven’t done extensive testing with items like a Microsoft Surface. I threw together this simple function you could use.

Have fun.