Updating Virtual Machines


Summary: Microsoft Scripting Guy, Ed Wilson, talks about the problem of updating virtual machines.

Microsoft Scripting Guy, Ed Wilson, is here. This afternoon I am sipping a nice cup of red berry tea. I also have a bowl of grapes and a bit of brie. The berry tea, grapes, and brie are a nice combination, and light enough that it makes a nice afternoon snack.

One of the great things I love about Windows 8.1 is that it has real Hyper-V built-in to it, and it has Windows PowerShell cmdlet support for managing those virtual machines. The performance is really good, and it means that I can create a virtual machine on my laptop that replicates virtual machines in production. It makes a great test environment.

My test network is completely isolated and I use the internal switch so the virtual machines can talk to each other. This is perfect for most occasions. The problem comes when I want to update those virtual machines.

Here is an overview of the scenario…

I need to first change from the internal switch type to a network adapter that uses the Ethernet connection. Luckily, I can do this while the virtual machine runs. I open Hyper-V Manager, right-click the name of the virtual machine, and choose Settings from the action menu. I then look for Network adapter under the Hardware section. I change the network adapter (virtual switch) to use the Ethernet network adapter from my host machine. This is shown here:

Image of menu

Now I need to go into the virtual machine and modify the network adapter settings. This means that I right-click the network adapter icon on the tool bar, I choose Open Network and Sharing Center, select Change adapter settings, find my network adapter in Network Connections, right-click the adapter, choose Properties, scroll down until I find Internet Protocol Version 4 (TCP/IPv4), and again select Properties.

Now I change from a static IP address to a dynamic-assigned IP address and DNS. This is shown here:

Image of menu

Then I click OK, click Close, X, X…wait for things to freeze a couple times, open Windows PowerShell, type IPConfig and look to see if I have a new IP address. If I do, great! If not, I need to investigate ipconfig/renew.

If that doesn’t work, I need to disable the network adapter, re-enable it, and type ipconfig/renew again. If that doesn’t work, I reboot the virtual machine. Usually that will work. Today, it looks like everything is going well, and that it works. I open Internet Explorer to verify that I have Internet connectivity. This also works.

So I open Control Panel, System and Security, Windows Update, and Check for Updates, and again wait a while…

As shown here, there are a few updates that I need to install:

Image of menu

And now I wait for a while again. Hmmm…

While I am waiting, I think I will go make a cup of tea. Back in a while…

Well, that all took a while, and now I need to reboot the virtual machine. Then I have to reverse the process: change back to the virtual switch, go back into the network adapter, and configure a static IP address.

So there is a description of the problem I face. When I have multiple virtual machines that I need to update, it takes a while. So, this becomes a great area for automation—and that is just what Sean will do tomorrow.

Join me tomorrow when I have a guest article by Microsoft PowerShell MVP and Honorary Scripting Guy, Sean Kearney. He will talk about performing an offline update.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy 

Comments (0)

Skip to main content