Step-By-Step: Creating A Simple Login Dashboard in Hyper-V 2012 R2

After installing Microsoft Hyper-V Server 2012 R2 or your Windows Server 2012 R2 is on Core version (without GUI enable) you realize that you don’t have much information at login regarding your local virtualization infrastructure.

Normally, when you login to a Hyper-V server you will get a command prompt and a running instance of the Server Configuration tool. For the first time, it’s very handy, but can be combersome afterwards. The reality is that most of the time you will be managing Hyper-V remotely from your own Windows computer. The only reason why you would want to login to a Hyper-V server directly is because something has gone wrong, and requires you to do some troubleshooting directly on the server itself.

When you want to troubleshoot the Hyper-V server, you want to see if your VMs are ok and ensure access to the PowerShell window is enabled so you can use the Hyper-V cmdlets to debug even further. Lets first launch PowerShell.

Step 1: Launching PowerShell from the Command Prompt

  1. From the command prompt type in PowerShell and hit enter
     

  2. Next run the following command:

    Set-ItemProperty "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\WinLogon" Shell 'PowerShell.exe -WindowStyle maximized'
     
    Note: After enabling this command the PowerShell window will be made available instead of the command prompt at the next login.

 

If you want a little more than that, and want a summary “state” of your VMs at login, like a PowerShell “Dashboard”, than you can create a PowerShell profile. The following script provided by Ben Armstrong, Microsoft's Hyper-V Program Manager, can help you enable said dashboard.

Step 2: Creating a PowerShell Profile

  1. Enter the follwoing in the PowerShell window to set the Execution Policy:
     
    Set-ExecutionPolicy RemoteSigned
     

  2. Next create the Profile File by entering the following:

    New-Item -path $profile -type file -force

    notepad $profile
     

  3. Copy the following script into the newly created Profile File

    # Maximize the window
    (Get-Host).UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(((Get-Host).UI.RawUI.MaxPhysicalWindowSize.Width-3),(Get-Host).UI.RawUI.BufferSize.Height)
    (Get-Host).UI.RawUI.WindowSize = (Get-Host).UI.RawUI.MaxWindowSize

    # Get the colors corrected
    (Get-Host).UI.RawUI.ForegroundColor = "White"
    (Get-Host).UI.RawUI.BackgroundColor = "DarkBlue"
    # Change path and clear the screen
    cd \
    cls

    # Display a welcome message
    write-host Welcome to $env:computername
    write-host
    write-host Current virtual machine status:
    get-vm
    write-host