Restoring Virtual Machine Creation Time

Restoring Virtual Machine Creation Time

21 Oct 2014 by Jeffery Hicks     0
 

 When using PowerShell to build reports about your virtual infrastructure, have you run into situations where you run a command like this:

Only to end up with output like this figure? What’s up with that creation time? If you run client Hyper-V on Windows 8 or Windows 8.1 you might be more likely to see this type of result although I have seen this behavior on Hyper-V server as well. Of course, if you stage a virtual machine on Windows 8.1 and later move it to a server, you will most likely carry over this problem. Perhaps this doesn’t bother you but data discrepancies like this bother me. So after a bit of research I found a few references to a bug on client Hyper-V where the creation time property is not captured. The creation time property is stored, or should be stored, in the virtual machine configuration file.… Read More»

Get Virtual Machine Last On and Off Time

Get Virtual Machine Last On and Off Time

17 Sep 2014 by Jeffery Hicks     0
 

 In the past I’ve written about how to identify old or obsolete virtual machines based on the time stamp of the associated VHD or VHDX file. The PowerShell techniques in that script get the job done and there’s nothing necessarily wrong with it, although it does make an assumption that you can reach the disk file remotely. But, as I was researching a problem, which will be the subject of another article, I discovered a new way to identify when a virtual machine was last turned on. In fact, I also found how to find when the virtual machine was last turned off and when its state changed, say from running to paused. The key is in the virtual machine configuration file. Virtual machine configurations are stored as XML files. The file name is the same as the virtual machine’s guid, or ID. You can use the Get-VM cmdlet in… Read More»

Customizing a Gen 2 VHDX disk using PowerShell

Customizing a Generation 2 VHDX

24 Jun 2014 by Jeffery Hicks     1
 

  In a previous article I demonstrated how to create a VHDX file that you could use when creating a Generation 2 Hyper-V virtual machine. If you recall, part of the process included creating partitions for recovery information. However, I didn’t do anything with them at the time so let me guide you on how to use these partitions and even speed up deployment of the new virtual machine. Many of these commands have command line counterparts but we will use PowerShell 4.0. This process will also require the Storage and DISM cmdlets. I will walk through the process with these items:

How did I know I wanted an index of 2? By looking at what is inside the WIM file with the Get-WindowsImage cmdlet. Part of my process will install Windows Server 2012 R2 Standard (GUI). Let’s begin. WARNING: You will be using commands that involve partitioning and… Read More»

Creating a Hyper-V Generation 2 VHDX file with PowerShell

Creating a Generation 2 Disk with PowerShell

05 Jun 2014 by Jeffery Hicks     0
 

    When Windows Server 2012 R2 hit the datacenter, and with it a new version of Microsoft Hyper-V, it offered the option to create a new kind of virtual machine. These “Gen 2”, or generation 2, virtual machines These VMs can now support UEFI boot, among other features. However, they also require a specific disk configuration. If you’ve been reading this blog for a while, you should have seen my other articles on creating and managing VHD and VHDX files using Windows PowerShell. So now it seems, we need to see what it takes to create one of these new Gen 2 devices which by the way are only compatible with 64-bit flavors of Windows 8.1 and Windows Server 2012 R2. To follow along, you will need to be running the most current version of Hyper-V, either on a server or a Windows 8.1 client. In addition to PowerShell… Read More»

monitor-hyper-v-event-logs-powershell

A PowerShell Based Hyper-V Health Report

28 Jan 2014 by Jeffery Hicks     32
 

    Over the course of the last year I’ve written a great deal about managing Hyper-V with Windows PowerShell. If you haven’t started tinkering with PowerShell to see what it can do for you, take a look at my articles here and get started! As I was writing all of these articles there was a long term project I had in the back of my mind and after a period of development and testing I think I’m ready to share it with you.

monitor-hyper-v-event-logs-powershell

Monitoring Hyper-V Operational and Admin Event Logs with PowerShell

18 Dec 2013 by Jeffery Hicks     4
 

  There is a lot that can happen to your Hyper-V server and fortunately most of these events, both good and bad, are recorded in the Windows event log. But monitoring these events can be a tedious process, especially if you rely on manual processes. This is a perfect situation where automation via Windows PowerShell can make your life much easier and help keep an eye on the health of your Hyper-V servers.

hyper-v-performance-counters-part-2

Hyper-V Performance Counters and PowerShell – Part 2

31 Oct 2013 by Jeffery Hicks     0
 

 In the previous part we explored techniques for getting performance counter data from your Hyper-V servers using PowerShell. Today we’ll continue poking around and look at some counters targeted more at the individual guests you may have running. Knowing what resources they are consuming can help you keep an eye on your overall server health as well as identify guests that may be running amok.

hyper-v-performance-counters-part-1

Performance Counters, Hyper-V and PowerShell – Part 1

28 Oct 2013 by Jeffery Hicks     0
 

  Monitoring the health of your Hyper-V server should be a daily task. One area you might want to consider checking are performance counters. If you can use a little PowerShell, you’ll find this is even easier than you might imagine. I’ll be demonstrating on a PowerShell 3.0 system, but these commands should all work on PowerShell 2.0. You don’t need PowerShell remoting and you don’t even need the latest and greatest Hyper-V server.

get-hyper-v-vm-last-use-revisited

Get-Virtual Machine Last Use – Revisited

10 Oct 2013 by Jeffery Hicks     2
 

 Recently I posted an article on using PowerShell to find when a virtual machine was last used. If you missed the original article, you might want to check it out as the concepts haven’t really changed. When I first wrote my PowerShell function, I made an assumption that it had to run locally. And for the most part that is still true. In order to get the actual VHD or VHDX file I need to be on the server because the path is relative to the server. Although sometimes you can run commands remotely from your desktop and get some information.

resize-hyper-v-vhd-files-with-powershell

Resize Hyper-V VHD Disk Files with PowerShell

23 Sep 2013 by Jeffery Hicks     2
 

    I’d like to think that we plan ahead and build Hyper-V virtual machines with adequate disk space. But sometimes our best plans can quickly fly out the window. Or you might have a legacy virtual machine that you can’t get rid of yet but its disk space is becoming an issue. Fortunately, this is easily remedied with the Resize-VHD cmdlet. Let me walk you through how I fixed such an issue.

moving-hyper-v-vm-storage-powershell

Moving VM Storage with PowerShell

01 Aug 2013 by Jeffery Hicks     6
 

    We all like to think that when we built our Hyper-V server that we carefully mapped out storage requirements. But if you are an IT professional that has been around for any length of time you know that sometimes the best laid plans can quickly go out the window. In short, there may be any number of reasons why you might need to relocate storage associated with a Hyper-V virtual machine.

manage-hyper-v-powershell

Manage Hyper-V with PowerShell

22 Jul 2013 by Jeffery Hicks     1
 

   If you’ve been reading my posts, you should realize I am a huge proponent of Windows PowerShell. The number one attraction for me, is that if I can run a command to process a single thing, like a file, user or Hyper-V virtual machine, I can probably do the same to 10, 100 or 1000 with very little additional effort.

get-hyper-v-vm-last-use-timel

Get VM Last Use Time

15 Jul 2013 by Jeffery Hicks     0
 

 I don’t know about you, but my Hyper-V box has a number of virtual machines. Many of them created for ad-hoc or testing purposes. I suspect you might be in the same boat. In most cases a running virtual machine indicates it is “in production”. But what about the other machines? How can I tell when they were last used? We can get creation time easy enough using PowerShell and the Get-VM cmdlet.

10-hyper-v-cmdlets

10 Awesome Hyper-V Cmdlets

07 May 2013 by Jeffery Hicks     8
 

  While the Hyper-V management console is cozy and can certainly get the job done, I think there are a handful of PowerShell cmdlets that can make your life easier. At least in terms of managing Hyper-V. These are commands that have a graphical counterpart, although sometimes it takes a little work to get to it. These are my top 10 cmdlets every Hyper-V pro should know, but in no particular order. All of these commands have help files so be sure to check them out as well. All references are to Hyper-V cmdlets that run on PowerShell 3.0.