Mini Hyper-V: Setup

Now that hardware has been installed on my mini Hyper-V project, next up is to setup the unit and get software installed. The Brix fires up very quickly and of course since nothing is installed I initially see the no operating system found message. Rebooting, pressing F2 gets me into the BIOS setup.

IMG_6536

The only thing I need to do on the first page is to adjust the date and time. I was hoping I could change the Project name to something such as Mini Hyper-V, but it doesn’t appear that is possible. On the Advanced tab, I’ll want to enable virtualization.

IMG_6537

You can see the Brix has a dual-core i7 processor. On the Advanced tab I can also verify the mSATA drive.

IMG_6538

Checking boot options I see that the unit only sees the internal drive.

IMG_6539

But the device supports EEFI and legacy boot options so I’m not expecting any problems. After saving my changes I even verified that F12 will bring up a boot menu, should I need it.

Next I need an operating system. I decided to try preview of Windows Server 2012 Hyper-V R2. I realize I’ll need to re-install when it is finally released. I don’t expect to run anything other than Hyper-V on this little box and Server Core keeps the footprint nice and small. But how do I get it onto the unit? Easy. I need to “burn” the ISO to a USB stick. To do that I’ll use the freeware, ISO to USB.

One thing I messed up initially, not really thinking, is that you need a decent size USB device. I foolishly started with 2GB only to realize I need at least a 4GB device.

ISOtoUSB

The utility will reformat the USB device. The one I was using had some pre-existing files and I had to try a couple of times to get the process to work. I think the best approach is to delete any files first, or even “pre-format” the device first. But once I got through that hurdle after about 7 minutes I had a bootable USB device which I inserted into the Brix and fired up.

The unit immediately detected the USB device and started the installation process.

IMG_6541

Excellent. I selected a custom install.

IMG_6542

By the way, I’m installing without a mouse but the keyboard shortcuts are more than sufficient. Install is very speedy. Copying the install files too literally seconds. Of course I’m installing Server Core but still very impressive.

IMG_6543

The overall installation took less than 3 minutes. Reboots are blazingly fast. Within minutes I had the initial screen to change the admin password.

IMG_6544

After struggling to get a password typed on my super mini keyboard, I’m eventually rewarded with the Server Core setup windows.

IMG_6545

I was wondering if I would need to load any drivers off the CD that came with the Brix, but so far I haven’t seen a need. I notice an occasional ripple in the video, but that could be an artifact from the ancient Dell monitor I’m using or the adapter. In any event it’s no big deal since once this is setup it is going to run headless anyway. The server got a DHCP address which is the most important element so I should be ready to start configuring the OS. I’ll cover that in the next post.

Browse TrainSignal Courses with PowerShell

talkbubble-v3It took longer than I expected, but my latest course for TrainSignal is now available. PowerShell v3 Essentials is targeted for IT Pros with little to no PowerShell experience. This is the course that will get you up and running in short order. I developed the course so that an IT Pro could be effective with the PowerShell console, using many of the new features found in PowerShell 3.0. One of those features is the Invoke-WebRequest cmdlet. I thought I’d share a version of a demonstration I did for the course on using Invoke-WebRequest to browse the TrainSignal course catalog.

In case you didn’t know, all of TrainSignal’s courses are now delivered online on a monthly subscription basis starting at $49/month. Their site has all the pricing information you need. But you can also start with a 3 day free trial. Oh, and lessons can be viewed offline as well. Anyway…using Invoke-WebRequest I can “scrape” the TrainSignal courseware page using PowerShell. Here’s my sample script.

The script saves the results from Invoke-WebRequest to a variable. In looking through the raw html I learned how the links were formatted and discovered that I only wanted links that started with /Course. I also figured out that the link objects had instructor and course information that could be parsed out of the OuterText property so I reformat the data into something more object-like.

I did this so that I could push the results to Out-Gridview displaying the courses.

get-trainsignalIn PowerShell 3, Out-Gridview can pass objects back to the pipeline, so I can select a few courses that look interesting, click OK, and the links will open up in my web browser.

I had a lot of fun creating this course and hope you find it worth your investment. Let me know what you think. And if there is a course you’d like to see me create, especially PowerShell related, let me know that too.

 

TechDays SF Presentations

TechDays_logo250 Last week I presented a number of sessions at TechDays in beautiful San Francisco. Met some great people and had a great time. I presented 4 talks, almost all of them PowerShell-related. Actually, they all had some type of PowerShell content. I’m happy to share my session slides and PowerShell demonstrations. Most of the demonstrations are not full-blown scripts but command examples, except for those things labeled as functions. If you did not attend TechDays, you are still welcome to download the material, although without the context of the live presentation some of it may not make sense. I hope you can make it next time.

File and Folders with Powershell 3
If you manage file servers and aren’t using PowerShell, you are working much too hard. Or if you are using PowerShell v2 you are still working pretty hard. Fortunately PowerShell v3 along with Windows 8 and Windows Server 2012 offer a much better solution. This session will demonstrate how to provision and manage folders, files and file shares using PowerShell from a Windows 8 client. With a little up-front work, you ‘ll be able to create provisioning scripts to deploy a new file share in seconds.

10 PowerShell mistakes, trip-ups and traps
Windows PowerShell is a language and management technology that many IT professionals, including developers, think they understand. Yet very often they get caught up in pre-conceptions and misinterpretations, usually based on prior experience with scripting or development. This session will explore the 10 most common mistakes and traps that people fall into with PowerShell and how to avoid them.

Troubleshooting Active Directory with PowerShell
Active Directory is one of those technologies that when it works, nobody notices. But when it doesn’t work, everyone does. Fortunately, Windows PowerShell and Windows Server 2012 make a terrific troubleshooting tool. In this session we’ll look at some common Active Directory problems, how to diagnose them and in some cases resolve, all with Windows PowerShell.

Building a Windows 8 Hyper-V lab
We all know the benefits of testing in a non-production environment. But sometimes resources are limited and having a test setup seems like a lot of work. But now that Windows 8 includes Hyper-V, you can setup a lab environment in very little time. This session will guide you through setting up a Hyper-V based test lab and how to get the most out of it using the PowerShell management tools.

If you didn’t catch me in San Francisco, I’ll be at TechMentor this fall in Las Vegas. More on that later. There’s a chance I’ll be back to the West coast later this year for more PowerShell goodness. Keep an eye on the blog for announcments. Or if your company is looking for training, let’s talk.

TechDays San Francisco

talkbubble-v3I’m very excited to announce that I’ll be presenting at TechDays San Francisco this year. The event runs May 2nd and 3rd. You can find the schedule here. Registration will be forthcoming. Seating will be limited so you won’t want to delay once it opens up.

As you might expect I’ll be talking PowerShell, plus a few other topics I hope you’ll find interesting. Everything is subject to last minute change but here are my current plans.

10 PowerShell Mistakes, Trips and Traps and How to Avoid Them

Windows PowerShell is a language and management technology that many IT professionals, including developers, think they understand. Yet very often they get caught up in pre-conceptions and misinterpretations, usually based on prior experience with scripting or development. This session will explore the 10 most common mistakes and traps that people fall into with PowerShell and how to avoid them.

File and Folder Provisioning with PowerShell and Windows Server 2012

If you manage file servers and aren’t using PowerShell, you are working much too hard. Or if you are using PowerShell v2 you are still working pretty hard. Fortunately PowerShell v3 along with Windows 8 and Windows Server 2012 offer a much better solution. This session will demonstrate how to provision and manage folders, files and file shares using PowerShell from a Windows 8 client. With a little up-front work, you ‘ll be able to create provisioning scripts to deploy a new file share in seconds.

Troubleshooting Active Directory with Windows PowerShell

Active Directory is one of those technologies that when it works, nobody notices. But when it doesn’t work, everyone does. Fortunately, Windows PowerShell and Windows Server 2012 make a terrific troubleshooting tool. In this session we’ll look at some common Active Directory problems, how to diagnose them and in some cases resolve, all with Windows PowerShell.

Building a Windows 8 Hyper-V Lab

We all know the benefits of testing in a non-production environment. But sometimes resources are limited and having a test setup seems like a lot of work. But now that Windows 8 includes Hyper-V, you can setup a lab environment in very little time. This session will guide you through setting up a Hyper-V based test lab and how to get the most out of it using the PowerShell management tools.

As I get more details I’ll share them here, on Twitter and on Google Plus.

Hyper-V ID Hash Table

Microsoft Hyper-VIn Hyper-V, one of the challenges (at least that I’ve run into) has to do with naming. In addition to a name, Hyper-V objects such as virtual machines, are identified with a GUID. Most of the VM-related PowerShell cmdlets will let you specify a virtual machine name. But sometimes you’ll run across the GUID and wonder what is the corresponding virtual machine. Here’s a WMI query using Get-CIMInstance that shows the currently open terminal connections to a few virtual machines.


PS C:\> get-ciminstance -Namespace root\virtualization -class msvm_terminalconnection | Select connectionID,installdate

connectionID installdate
------------ -----------
Microsoft:13876524-BFD8-40A1-95E3-926E37ACFBAB\1 1/3/2013 11:27:50 AM
Microsoft:80E967E6-57F9-4ECF-998A-D07B20B2287F\2 1/3/2013 8:12:56 AM
Microsoft:E1EDE8DA-D632-4F77-81C4-B117FFF1FE15\1 1/3/2013 8:08:35 AM

The GUID in the connection ID corresponds to a virtual machine. Here’s my approach for “translating” the GUID to a name. Every VM has an ID.


PS C:\> (get-vm chi-dc01).id

Guid
----
f7d3ad8b-6329-43a3-991e-8a630a94ec40

There is also an VMID property but that is merely an alias to ID. As you can see, the ID is a GUID object so to get just the GUID string takes another step.


PS C:\> (get-vm chi-dc01).id.guid
f7d3ad8b-6329-43a3-991e-8a630a94ec40

Now that I know how to capture this information, I can build a “lookup” object using a hash table.


PS C:\> Get-VM | Group-Object -property {$_.ID.GUID} -AsHashTable -AsString

Here’s what I end up with:

vmidhash

Naturally, it makes more sense to save this to a variable.


PS C:\> $vmhash = Get-VM | Group-Object -property {$_.ID.GUID} -AsHashTable -AsString

The VM GUID is the key and the VM object is the value. I can get items a few ways.


PS C:\> $vmhash.'13876524-bfd8-40a1-95e3-926e37acfbab'

Name State CPUUsage(%) MemoryAssigned(M) Uptime Status
---- ----- ----------- ----------------- ------ ------
CHI-FP01 Running 0 761 03:34:51 Operating normally

PS C:\> $vmhash.item('13876524-bfd8-40a1-95e3-926e37acfbab')

Name State CPUUsage(%) MemoryAssigned(M) Uptime Status
---- ----- ----------- ----------------- ------ ------
CHI-FP01 Running 0 761 03:35:11 Operating normally

PS C:\> $vmhash.GetEnumerator() | where {$_.name -match '13876524-bfd8-40a1-95e3-926e37acfbab'} | se
lect -ExpandProperty Value

Name State CPUUsage(%) MemoryAssigned(M) Uptime Status
---- ----- ----------- ----------------- ------ ------
CHI-FP01 Running 0 761 03:36:29 Operating normally

Now I can add some logic to my Get-CIMInstance command to resolve the GUID to the VM name.


$vmhash = Get-VM | Group-Object -property {$_.ID.GUID} -AsHashTable -AsString

Get-CimInstance -Namespace root\virtualization -class msvm_terminalconnection |
Select @{Name="Started";Expression={$_.installdate}},
@{Name="RunTime";Expression={(Get-Date)-$_.InstallDate}},
@{Name="VM";Expression={
#define a GUID regex
[regex]$rx="(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}"

$guid = $rx.Match($_.ConnectionID).Value
$vmhash.item($guid).Name
}}

I also tweaked a few other properties. I extracted the GUID using a regular expression and then found the corresponding entry in the hash table. I could have added a little extra logic to test if the GUID existed as a key but I decided to just plow ahead.

vmidhashlookup

The hash table makes it very easy now to resolve virtual machine GUID’s to a user friendly name.