• Scripting: Hyper-V - Mount VHDs by right clicking

    There are plenty of posts on the interweb that show you how to mount and unmount vhds via powershell.  I downloaded the Hyper-V PowerShell management library from CodePlex.com here as created by James O'Neil.  In it he kindly provides two scripts (mount-VHD.ps1 and Unmount-VHD.ps1) along with a REG file.  Assuming you have PowerShell 1.0 installed (available feature in Windows Server 2008) these scripts and registry settings work fine. 

    I ran into problems once I downloaded and installed the Windows PowerShell 2.0 Community Technology Preview (CTP).  Powershells execution policy wouldnt let the scripts run anymore.

    You can change the executionPolicy a number of ways:

    Registry:  

    HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell

    Change the key: REG_SZ ExecutionPolicy to Unrestricted

    PowerShell:

    set-executionpolicy unrestricted

    Note: By changing the execution policy you are technically opening your system up to remote execution of PowerShell scripts from unsigned/untrusted sources.  I want to be able to mount vhds easily coz Im a lazy kinda guy.   Im running Hyper-V on my laptop so Im not too concerned about security in this instance.  You should think carefully about making this change in a production environment.

    The second thing I noticed was that the registry settings provided by James no longer worked.  So I came up with a slight modification as follows:

     Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Virtual.Machine.HD]

    [HKEY_CLASSES_ROOT\Virtual.Machine.HD\DefaultIcon]
    @="%SystemRoot%\\system32\\imageres.dll,26"

    [HKEY_CLASSES_ROOT\Virtual.Machine.HD\shell]
    @="Mount"

    [HKEY_CLASSES_ROOT\Virtual.Machine.HD\shell\Mount]

    [HKEY_CLASSES_ROOT\Virtual.Machine.HD\shell\Mount\command]
    @="cmd /k \"powershell -NoProfile -Command \"& 'c:\\Program Files\\Hyper-V\\Mount-VHD.ps1' '%1'\"\""

    [HKEY_CLASSES_ROOT\Virtual.Machine.HD\shell\Unmount]

    [HKEY_CLASSES_ROOT\Virtual.Machine.HD\shell\Unmount\command]
    @="cmd /k \"powershell -NoProfile -Command \"& 'c:\\Program Files\\Hyper-V\\Unmount-VHD.ps1' '%1'\"\""

    [HKEY_CLASSES_ROOT\.vhd]
    @="Virtual.Machine.HD"

    I've used cmd/k instead of cmd/c so I can see what the PowerShell script reports when its finished along with a couple of changes to get PowerShell to accept the string after the -Command.

    Now all is great in the land of Hyper-V on my laptop.

     

  • Windows 2008 Clustering & the Cluster Log

     

    Where is the cluster log in Windows 2008 ?

    This short answer is its no longer there. On our Windows 2008 cluster node if we navigate to %systemroot%\system32\LogFiles\Cluster your wont find the cluster.log file anymore.

    Why ? Its been replaced by a much more sophisticated event based tracing system.

    The Vista\Windows Server 2008 Event Model is the next generation of Windows Event Logging and replaces the current version of the Event Log shipped in Microsoft® Windows® 2003 Server, Microsoft® Windows® XP, Windows 2000, and previous versions of Microsoft® Windows NT®.

    The new model is a major update to the NT Event Log service. It maintains 100% backwards compatibility with the existing APIs and functionality and fully leverages the existing NT Event Log instrumentation in the applications and services. At the same time, it eliminates some of the limitations of the NT Event Log and provides additional features to better support monitoring and diagnostics of Windows applications, services, components, and drivers.

    In a future post I will go through the new Logging and tracing features for clusters in Windows 2008 but for now lets look at how to get access to the old familiar cluster.log file.

    Here's how to go about it.

    1.   Go to a command prompt

    2.  Type "Cluster /Cluster:yourclustername log /gen /copy "C:\temp". You should get output as follows

    image 

    3. Navigate to the c:\temp directory and there you will find the .log files for each node of your cluster.

    The cluster log can now be opened in Notepad.

    Please note that you need to run this command after each change as its not dynamically updated like the old .log file.

  • Cluster node /forcecleanup & Error -2147352567

     

    This is a not so common issue I can across this week . The background is as follows.

    • You decided to evict a node from your cluster.
    • There is a communication failure between nodes and a warning appears that the cluster was unable to remove clustering components from the evicted node.
    • You log onto the node in question and from a command prompt run "cluster node /forcecleanup"

    The command responds with the output show in the screen shot below

     

    1

     

    Your server is now in limbo. You cannot un-install the cluster service and you cannot re-join the cluster, the cluster network driver and cluster disk driver are still online. Most people would re-install the server from scratch at this point. There is however a workaround that will save you time.

    1.    Open up regedit on the system in question & Navigate to HKEY Local Machine\Software\Microsoft\Windows NT\Currentversion\Cluster Server

     

    2

    2.   Right click ClusterInstallationState and choose Modify

    3.   Change the value to 3

    3

    4.   Click OK

    5.   Exit Regedit and reboot your server.

    6.   Log back into windows and go to a command prompt.

    7.   Run "Cluster node /forcecleanup" you should see the following output

    5

    That's it !! No rebuild required. You can now operate the node as a stand alone box or join another cluster.