Windows Server 2012 (8 beta) Hyper-V enabled inside a VMware Fusion VM

I did see that a new version of VMware Fusion has been released as a technology preview and in the release notes I could find that it was possible to run ESXi host-vm with nested 64 bit VM´s in. Of course I had to test and see if I also could get a new Windows 2012 (8 beta) with Hyper-V role enabled and running.

There was some problems that had to be adressed before I got it working, google and help from fellow IT-neerds that had done the same in VMware Workstation solved my problems. And yes it is actually usefull, because I can run a test environment on my Apple laptop to test/demo things 🙂

After a clean install i got this error when trying to enable

I had to add these lines to the vmx file inside the VM package

hypervisor.cpuid.v0 = FALSE
vhv.enable = TRUE

I also manually set the preferred virtualization engine to Intel VT-x with EPT

Then i could add the Hyper-V role, but when rebooting i got a nice new kind of blue screen with the error HAL_MEMORY_ALLOCATION.

That was solved with the following line in the vmx file, I have no idea what it means exactly but it has to be something with the memory allocation,

mce.enable = TRUE

Here you can see my screendump on my Hajper-V VM with a Hyper-V VM running inside it 🙂

I have not installed VMware tools in the host, this because when enabling the Hyper-V role the OS that is installed becomes an Parent VM, so the tools will not be utilized on the Fusion VM´s hardware.  

 

A PowerShell function for Snapshot reporting in VMM2012

Hello

I am in the hotel waiting for the MMS 2012 to start so there is time for some automation ;-). Last week when I was teaching a course one of the attendes said after I showed the custom value function, that he also wanted a similar function for easy in the console check how many snapshots every VM had. In the VMM 2012 console I have not found an built-in function to actually show this.

I have modified the function and created the run script, this is scheduled to run once a hour so you have a updated view of your environment. At least in the Hyper-V for Windows 2008 R2 it is not recommended to use in production.

It is quite easy to create a new custom property that we then will populate,

New-SCCustomProperty -Name "Snapshot Count" -Description "" -AddMember @("VM")

In the GUI there is no way to remove a custom property, I can only remove it from assigned properties. During the course I created an property just for showing and want to get rid of it. Of course there is a powershell cmdlet for that:

Get-SCCustomProperty -Name "Muuuu" | Remove-SCCustomProperty

But now to the part of getting the script to show snapshots (yes I know, in VMM it is called Checkpoints but i refuse to call it that)

First I have the PowerShell function

function Set-CVSnapShot{
<#
.SYNOPSIS
Function to Update custom values for VM´s in VMM 2012
 
.DESCRIPTION
Use this function to  set the custom value Snapshot count
 
.PARAMETER  VMs
Use this parameter to update just that VM´s custom snapshot value
 
.NOTES
Author: Niklas Akerlund / RTS
Date: 2012-04-16
#>
    param (
   [Parameter(Position=0,HelpMessage="A virtual machine pleaze",
    ValueFromPipeline=$True)]
    $VMs = " "
    )
   
  	if ($VMs -eq " "){
    	$VMs = Get-SCVirtualMachine
	}else{
		$VMs = Get-SCVirtualMachine  $VMs
	}
	
  	$CustomSnapShot = Get-SCCustomProperty -Name "Snapshot Count"
   
	foreach ($VM in $VMs){
		$count = ($VM | Get-SCVMCheckpoint).Count
		
	    if($count -ne $null){
	        Set-SCCustomPropertyValue -InputObject $VM -CustomProperty $CustomSnapShot -Value $count 
	    }else{
	        Set-SCCustomPropertyValue -InputObject $VM -CustomProperty $CustomSnapShot -Value 0 
	    }
   }
}

then I have a very easy script that I task scheduled in my VMM server

# Script to use for scheduled updates of Custom values
#
# Niklas Akerlund / RTS 2012-04-16

ipmo 'C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager\bin\psModules\VirtualMachineManager' | Out-Null

. .\Set-CVSnapshot.ps1
Set-CVSnapshot

And in the VMM Console it looks like this

I will talk to some VMM responsibles at MMS and see if they find an interest and build the view instead of me running it in a sheduled task (as the information is there in the database)

Importing VM´s with PowerShell into Win8 Hyper-V 3.0

I am working on setting up my lab environment for the M50273 Design course that I am going to teach next week.

The import process is a bit heavy without powershell, cause it is 18 VMs that has to be imported. In a MOC (Microsoft Official Course) the lab setup consists of several VM´s that have base vhd disks and then several tiers of differential disks that need to be connected before import, in every directory there is a .bat file that creates the symlinks, I decided to keep them but run them in a script.

And here you can see the result of running the .bat file

The setup guide for the course says that I should install a Windows 2008 R2 host and then import the VM´s but i want to use Win8 instead, this to be able to run the built-in hyper-v cmdlets and also test if I could run the course VM´s on it.

I did not have this problem (Matthew Dowst) when importing my VM´s to the host but another networking issue occured, when checking the VM settings as you can see in the screen dump that the virtual network adapter is there but not working correctly, a little powershell again helps 😛

And this powershell command that takes the network adapter on the vm and connects it to the Internal switch :

Get-VM *HOU-DPM-E* | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName Internal

So then it looks like this in VM settings:

So to automate the import process I created a small script that looks in a directory for VM´s in folders to import, then starts each .bat script to create the symlinks and imports the machine and lastly renames it (cause in the import process it is named REARMEDxxx) and connects the vm to the right network

As you can see, in this script i have not created a function or fancy parameters, that might come in a version 0.2.

# Import VMs for Course
#
# Niklas Akerlund / RTS 2012-04-04

$VMs = Get-Item -Path "E:\Program Files\Microsoft Learning\50273\Drives\*" | Select-Object Name,FullName

foreach ($VM in $VMs){
    
    if(Get-VM $VM.Name -ErrorAction SilentlyContinue ){
        Write-Host $VM.Name "Already imported"
    }else{
        # Create Symlinks
        $symbat = (Get-Item ($VM.FullName + "\*.bat")).FullName
        & $symbat

        $expfile = (Get-Item ($VM.FullName + "\Virtual Machines\*.exp")).FullName
        
        Import-VM -Path $expfile 

        Get-VM REA* | Rename-VM -NewName $VM.Name
        Get-VM $VM.Name | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName Internal
    }
}

It looks something like this when running

And when it is done I have all my 18 VMs imported and with the right network connected:

Virtual Machine Snapshots in Win8 Hyper-V massage with PowerShell

In the new win8 there is a function to merge the snapshot taken on a VM without putting it into saved state/turn off. In the Windows 2008 and 2008 R2 there was a big no-no to taking snapshots on production machines, how about now in the new version? Well their replication function uses snapshots so it must be good enough. Then as always you should consider the consequences of taking snapshots and rolling back on different systems as the data in a database may be lost when jumping around.

The Cmdlets that are relevant for Snapshots :

  • Checkpoint-VM
  • Get-VMSnapshot
  • Remove-VMSnapshot
  • Export-VMSnapshot
  • Restore-VMSnapshot
  • Rename-VMSnapshot

If you search among the cmdlets the first CheckPoint-VM is not very easy to find, I am woundering why they(MS) has decided that name?! (I have before complained about checkpoint in SCVMM, maybe it is from there it has the roots)

Here is a PowerShell oneliner that makes 50 Snapshots on a VM (the limit of 50 snapshots is still valid as i tested to make 60 snapshots and got errors from 50+)

for($i=1 ;$i -le 50 ; $i++){Checkpoint-vm -SnapshotName $i -VMName lajs}

Here is the error.

How do I know how many snapshots i have on a VM?

Or if you must, check the GUI..

When I now have 50 snapshots I have to remove one before taking a new, the Remove-VMSnapshot has a parameter -IncludeAllChildSnapshots that is quite handy if you have like me 50 snapshots that you want to remove. I use the Select-Object -First 1 to get the first snapshot so i can remove all at once.

Get-VM lajs | Get-VMSnapshot | Select-Object -First 1 | Remove-VMSnapshot -IncludeAllChildSnapshots

How about the cmdlet Export-VMSnapshot, it cannot be run when the VM is running, but it creates an exported VM that is from the snapshot. This can be very useful if you want to have a machine from a specific snapshot built.

How to go to a snapshot with Restore-VMSnapshot then, when I restore I have to confirm but not when deleting?

If you haven´t found the reference page on technet for WIN 8 Hyper-V powershell cmdlets it is here.

Automatic installation of SCVMM 2012 RC & SQL 2008 R2 and WAIK 3

Today I have been researching how to make a script that deploys a working installation of a VMM 2012 RC with a local SQL server without needing to manually type in anything.

What is strange is that the WAIK itself does not give you an option to do a quiet install! I had to use msiexec Transform to massage it to allow for an unattended install.

I used this MyITforum page to get a SQL config file, and this post by Christoffer got me the waik installation bit.

One thing i changed in the SQL config was this line:

SQLCOLLATION=”SQL_Latin1_General_CP1_CI_AS”

because when i install on a OS with Swedish it will try to install with another Collation, this is no worries until you want to use this database server for SCOM 2012, because it requires the above Collation! 🙂

I am using the Start-Sleep cmdlet to get some time between the installations, also I have a check that the Setup process is still running and delay until it has finished,

You will have to download the WAIK 3.0 and the SCVMM 2012 RC, also you will have to copy all files from the SQL 2008 R2 ISO into a folder, as my script refers. Copy the content to subfolders like my screen dump and you should get it working. The .Net feature is installed during the SQL installation so i do not need to add it on its own.

# Install VMM unattended
#
# NIklas Akerlund /RTS

# Install the SQL server
c:\install\sql2008r2\setup /ConfigurationFile=c:\install\ConfigurationFile.ini

# Install the WAIK
msiexec /qb /i C:\install\KB3AIK_EN\wAIKAMD64.msi TRANSFORMS=c:\install\waikamd64.mst

Start-Sleep -s 60
# Install the VMM server and console

C:\install\vmm12\setup.exe /server /i
Start-Sleep -s 30
while (Get-Process | where {$_.ProcessName -eq "SetupVM"}){
Write-Host "Still installing server"
Start-Sleep -s 2
}
Start-Sleep -s 10
C:\install\vmm12\setup.exe /client /i
Start-Sleep -s 30
$Process = Get-Process | where {$_.ProcessName -eq "SetupVM"}
while (Get-Process | where {$_.ProcessName -eq "SetupVM"}){
Write-Host "Still installing Console"
Start-Sleep -s 2
}

When i run it, it looks like this

There are some configuration files that could be used to set up other parameters for ports/license keys etc and they reside in the VMM setup directory and their names are VMServer.ini and VMClient.ini, for my demo/test setup i decided to not change anything. If you want to know more parameters in the VMM setup, just run in powershell console or CMD, setup /? and you will get a dialog with options

System Center Online Seminars: Deep Dive VMM 2012

Today Me self and Joachim Nasslander did our last Live Meeting about the System Center VMM 2012 in swedish for Microsoft. We did not have time to show all our demos so i thought that it would be an idea that i show them here in a blog post. There is no sound on the demo-videos, hopefully the LM that was recorded will show up on the Swedish MS technet soon…

The first thing that i showed was the Bare Metal Deployment of hosts, this is done with the help of a prepared VHD and a WDS (Windows deployment Server) that is registered to the VMM server. I have cut a bit of the waiting when the server was finalizing the configuration.



The next demo was after deployment of the host I used the built in functions in VMM 2012 to add hosts to a cluster




After this I show how to use the integration between the WSUS and the VMM which gives the opportunity to update a cluster and set the cluster nodes into maintenance mode and then update rolling through all hosts and the VM´s live migrating to the hosts.



I also made a demo on how to v2v migrate a VM from vSphere host to a hyper-v host when they are all connected to the same VMM 2012




Lastly I have made a demo on how to use Powershell within the VMM 2012 and how to use it to both do reporting and changing things, I have already made some blog posts about how to use the VMM 2012 powershell cmdlets.



Using SCVMM 2012 SP1 CTP to administer my Win 8 Hyper-V hosts

This night I saw that MS, listened to my tweet 😉  where I asked for possibility to manage Hyper-V 3 with the SC VMM2012. I have children that let me wake early and so I could start immediately to investigate the new SP1 and see how it works to handle Win8/HyperV3 hosts.

In my test environment I have two hosts  hyp31 and hyp32, I have also a virtual machine for the VMM (vmm3) and a virtual file server all of them running the Win8 Server Beta.

The installation was pretty straight forward, The only problem was that I had to have a internet connection to be able to get the .Net 3.5 feature installed.

When the VMM server and console was Installed I could login and add some hosts

As I already had set up the host and had VM´s on the fileshare it was easy to start testing Live Migration between the hosts (they are not in a cluster but both can access the fileshare).

Get-SCVirtualMachine MAJS | Move-SCVirtualMachine -VMHost HYP31 -Path "c:\VMs"

I have to use the -Path parameter but only a xml config file resides on the host and my vhd harddisk remains on the fileshare \\win8fs\vmds , will do some research building a cluster and see how that works with the files later..

 

Using Windows PowerShell Web access for VMM2012 Administration

Today i had the pleasure to install and configure the Windows PowerShell Web Access in Windows 8. This gives you an opportunity to administer your internal servers with a Web Powershell Console. The really nice part here is that when I have enabled this I can connect to an Windows Server 2008 R2 with Powershell v2.

I have configured it with Authorization to everything, now this is a test environment but in your maybe you should be more restrictive,

Get-WindowsFeature WindowsPowerShellWebAccess | Add-WindowsFeature
Install-PswaWebApplication -UseTestCertificate
Add-PswaAuthorizationRule * * *

So I can connect with for example a Ipad and administer my Hyper-V Cluster in SCVMM2012 😛

In this link you can see how to configure this on your Windows 8 Server Beta.

Here is the login prompt…

And here you can see how i run commands in the console, As you can see I must use Import-Module to import the VMM 2012 cmdlets before I can use them. This is a flash embedded video from youtube (where i uploaded it to) If you do not see it you can go to this link


I still have to find out why I cannot use the PowerCLI PSSnapin, I get an OutOfMemory exception when trying to connect-viserver 🙁 will have to dig a bit deeper to check that one out. Maybe there is a bug in the PSSnapin, an excellent time for VMware to make a Module instead!

Enable/Disable Core mode on Windows 8 Server Beta

Today I have been researching about how to enable and disable the GUI on the Windows 8 Server beta. As it is a best practice to run your Hyper-V hosts in Core I wanted to know how to do this, you might want to configure some things in full GUI mode and then run the server in core after you are done. Going from the full gui to Core was quite easy, i just ran the following commands in powershell and rebooted, then i was in the cmd console world of Core.

When i then wanted to get back to the GUI world i just ran the command Add-WindowsFeature instead of remove

Then i had to test to install a Core and try to get it to full. The Beta does only have two editions to choose from.

When the machine was finished i tried to use the Sconfig tool that is a configuration helper in Core, and in that you have a selection 12 that are supposed to enable GUI, but despite that it said 100% nothing happend, so this was a bit trickier because when i choose the Core in the installation, not all files are deployed in the installation, this to save space and unnecessary files/functions. This does however create some extra work when you realize that you want the GUI, at least nowadays you do not have to reinstall the whole machine :-).

How do i solve it then, I found a presentation from Jeffrey Snover and Andrew Mason at the Build conference which led me to the imageX binary that i can mount the install.wim file. one would think that just mounting the win8 ISO would be enough but no, i had to do some imageX magic, i used the one from the Win7 WAIK and copied it into the core machine, as i am a ps-fan i copied it with powershell ,then i had to mount the wim file with the imagex and then run the cmdlets to enable the GUI. At least it feels easier using powershell than DISM /Online bla bla..

copy-item \\win8fs\share\imagex.exe c:\temp

mkdir c:\win8wim

.\imagex.exe /mount d:\sources\install.wim 2 c:\win8wim

I ran the following, and as you can see i had to specify the windows folder on the wim where the winSxS (this is where the missing files are) is a direct subfolder,

Get-WindowsFeature Server-G* | Add-WindowsFeature -Source C:\win8wim\windows
Restart-Computer

When going from core -> full or the other way around it is some waiting when the configuration is done.. it is not quite as easy as the Linux and the run-levels (init 3, init 5), maybe MS should have been looking a bit there when implementing their solution.

Update: As Snover commented below, it actually works to use sconfig and “Restore GUI”, but this is when your server is connected to the Internet and can download the files needed, I tried it and it took over 1 hour and then it asked for a restart to finish. Not every organisation do connect their servers directly to the Internet, maybe it could work then with a local WSUS server?!

Managing Hyper-V 3.0 Host and VM´s with powershell

So now i have started digging into the powershell cmdlets that are available for the Hyper-V in Windows 8 Server beta. As you can see on my screendump and also on this link there are some, i would love to see some extensions when the product becomes RTM, I am spoiled with the functionality and extensibility of the PowerCLI 😛

One thing that i like is that with powershell it is easy to actually find out what NIC you want to use in your virtual switches, why Microsoft insists of showing the description instead of name in the Hyper-V virtual switch admin gui? i have no idea which nic is which,

I do have a good name for them in the Network Connections

in the wonderful world of powershell it is now easy to create a virtual switch and actually get the right nic, also with the parameter -AllowManagementOS i make sure that my Host will not share this nic.

New-VMswitch -Name Intern -NetAdapterName VMSwitch -AllowManagementOS $false

Then i can deploy my VMs, I am woundering why the virtualization team is using bytes in their parameters ? -MemoryStartupBytes -NewVHDSizeBytes, fortunately you can use -MemoryStartupBytes 512MB or 1GB and powershell calculates it to bytes. Another thing that I am wondering about is that when i create a VM i cannot set number of vCPU, i have to change that after the VM has been created?!

New-VM -Name vNiklasDC -NewVHDSizeBytes 20GB -SwitchName Intern -MemoryStartupBytes 512MB -NewVHDPath C:\VMs\vNiklasDC\vNiklasDC.vhdx
Set-VM -Name vNiklasDC -ProcessorCount 2 -DynamicMemory -MemoryStartupBytes 512MB -MemoryMaximumBytes 1GB

More updates will come as i discover more about the new Windows 8 Server beta..