• Moving VHDs for a virtual machine in Hyper-V on Windows 8.1

    I’ve been using virtual machines to test out some software, but those VHD files take up a bit of disk space – so much that my PC’s solitary SSD drive was running out of room. Thankfully the Lenovo hard disk drive bracket kit arrived today so I can install an extra drive to supplement the SSD.

    Now to move the VHD files to the new drive.

    The instructions described here, whilst for Windows Server are essentially the same for a Windows desktop OS. The only difference is that the Move Wizard doesn’t offer the Move the virtual machine option. eg.

    Hyper-V Move Wizard dialog on Windows 8.1

    Of course, you can do this with PowerShell too (and I did):

    Move-VMStorage -VMName W12R2-1 -DestinationStoragePath d:\VHDs\W12R2-1

    And you even get a nice progress bar!

    PowerShell console showing Move-VMStorage with progress

    You also get the migration progress in the status field in Hyper-V Manager.

    Hyper-V Manager with VM showing Moving Storage status

    A few minutes later, the VHD was successfully moved to my new hard disk, and because this happened live, the VM kept running the whole time. Impressive!

  • PowerShell and (not) parsing command lines

    A short reminder note for myself.

    To tell PowerShell to not parse the remainder of a line, use --%. This is invaluable when calling out to external commands and you don’t want to escape every special character with a backtick (`).

    So instead of this:

    icacls X:\VMS /grant Dom\HVAdmin:`(CI`)`(OI`)F

    You can write this:

    icacls X:\VMS –% /grant Dom\HVAdmin:(CI)(OI)F

    See the Stop Parsing section in Online Help for more info.

  • Glimpse and Castle Windsor

    Some breaking news in the last week – Microsoft has taken over the sponsorship of Glimpse – an open source diagnostic platform for web applications. Glimpse has been described as the server-side equivalent of your browser’s F12 Developer Tools, so it’s great that first Red Gate and now Microsoft have recognised the value of this tool and supported its development.

    I’ve been making use of Glimpse recently to get some more insight into the timing of server-side code. It hooks into the ASP.NET pipeline and gives a useful breakdown of various activities. Depending on what you’re using with your web application, there’s extra extensions that you can add to glean more information – like Web Forms, Entity Framework etc.

    Even for things like an Inversion of Control Container can provide interesting data. There’s already extensions for AutoFac and Ninject, but not for Castle Windsor – one of my preferred IoC containers.

    I know that there are quite extensive diagnostics provided by Castle’s container – but usually you only see these when you’re debugging, so I thought it might be possible to expose the same information to Glimpse.

    And so I created the Glimpse.Castle extension.

    It adds a new tab to to the Glimpse dashboard with all that useful detail from the Castle container’s diagnostics service.

    Web browser showing Glimpse dashboard

    The extension source code is on Github and currently you can build it and run with the latest release of Glimpse. When I get a chance I’ll get it published on NuGet and get it added to the extensions page on the Glimpse website.