My experience on the newly released VMM 2012 R2 RTM

So as everyone else (at least an ITPRO with some dignity and self respect) I have started to download the System Center 2012 R2 as it was released just some hours ago! The link appeared on my technet subscription page about 1 PM in Swedish time

Screen Shot 2013-10-17 at 13.06.16

I started to Install the VM for my VMM and of course I created it as an Generation 2 VM on my Hyper-V R2 host.. In the preview, VMM could not manage gen2 VM´s but now we will see about that. Before installing VMM I had to download and install Windows 8.1 ADK and an SQL server.

Screen Shot 2013-10-17 at 14.26.04

And then when I had an successful installation I wanted to add at least one Hyper-V server, the funny part here is that I have activated Hyper-V on this Windows 2012 R2 and why it is saying unknown hypervisor beats me 🙂 . Fortunately I could proceed to add the host

Screen Shot 2013-10-17 at 14.44.26

And then I wanted to check the Gen2 VMM server I had created and see if it was viewable in the VMM console and also the system volume could be expanded when the VM was powered on (in earlier versions of VMM that has sometimes been a nono for example with VM additions )

Screen Shot 2013-10-17 at 14.51.09

Screen Shot 2013-10-17 at 15.04.35

As you can see there is no possibility in the VMM console to shrink the disk so there I have to use the Hyper-V Manager.. ( I have tried to enter a lower value but the gui won’t allow me to do it) So much for one place for all management.. In the following screendump you can see the option to shrink the storage from the Hyper-V manager wizard.

Screen Shot 2013-10-17 at 15.06.42

 And as you remember one of the new fine features in the Hyper-V R2 was the full feature RDP access to the VM through the VMbus, why has that not been implemented in the VMM??

Screen Shot 2013-10-17 at 15.14.40

 This old vmm viewer reminds me of the VMM 2008 with no additional features that I get in the Hyper-V Virtual machine connection..

Screen Shot 2013-10-17 at 15.15.56

I will continue to explore the VMM 2012 R2 and there might be some more blog posts coming and until then, good luck in your deployments 🙂

Converting VHD´s to VHDX in SCVMM 2012 SP1 with PowerShell

I have in an earlier post described my little PowerShell function to migrate VM´s from a Windows 2008 R2 cluster to a new Windows 2012 Hyper-V cluster in VMM.

As it is a best practice to convert your VHD´s to VHDX I wanted to do that with SCVMM 2012 Sp1 also. It is a small detail that you need to be aware of when doing it in the VMM console, it does not remove the old VHD file from the datastore and in the GUI it is no checkbox for that either. This is the case for both VMM 2012 SP1 and R2 Preview. And if you start converting several VM´s VHD´s there is a possibility that your datastore will become full quite fast and that is not so good!

Screen Shot 2013-10-04 at 14.39.44

And on the folder where the virtual harddisk resides you can see that the vhd still exists..

Screen Shot 2013-10-04 at 14.57.15

In the PowerShell cmdlet Convert-VirtualDiskDrive there is a parameter -deletesource that removes the VHD once the conversion has completed 🙂

So I have made a PowerShell function if you want to convert all your VHD´s on the virtual machine.

Good luck in getting the Hyper-V 2012 environment in the best shape ever before moving to 2012 R2!

New PowerShell VM Inventory Script for SCVMM 2012 SP1/R2

about 1 1/2 years ago I made a script for Inventory Reporting in SCVMM 2012 and now I have been working on an update that supports VMM 2012 Sp1 and R2, there have been some changes in the cmdlets so now it was time to refresh it and add some information.

In VMM 2012 R2 the possibility to get the IP address has been added so I utilize that from VMM, if you are using the SP1 version I can get the IP address from the Hyper-V PowerShell module and the cmdlet Get-VMNetworkadapter, that works only on Hyper-V 2012 Hosts and the Integration components have to be updated. The function reports the number of NIC´s and VHD´s but not show all, I have chosen to just add one virtual NIC and three virtual hard disks in this, that can be altered if you want and just add in the hash table.

In this new function I have added a switch parameter that lets you select if you want a html/csv report or just work with the objects that comes out of it when running 🙂

To use it you can just use one of several ways with parameters

Screen Shot 2013-09-29 at 22.38.05


And here is the script function

And here is an example of the csv report, and yes it is much info, the CSV can be scrolled quite a bit 🙂

Screen Shot 2013-09-29 at 22.27.45

You can select what you want included in the report by just using the function and pipe it to Export-CSV



Migration script for VM´s moving to Hyper-v 2012 from 2008r2 with VMM

As you might have been reading on my blog about the implementation of the SCVMM 2012 SP1 I have been doing at a customer and the challenges with networking and hosts.

Now the turn has come to migrate those VM´s that reside on the old 2008 R2 cluster to the new shiny Hyper-V 2012 cluster. The approach this time has been to use the VMM and migrate them between the clusters.

VMM 2012 SP1 has some shortcomings when it comes to different configured clusters and their networks. With a bit of crafty PowerShelling I solved that.

So the error was that I could not set the network that I wanted in the migration on the target.. In the VMM Console I get a error and could not continue :

Screen Shot 2013-09-26 at 09.47.36

Then I thought that its maybe an issue in the GUI and can be override in the PowerShell console but NOOOO there exist no parameter for setting the virtual switch 🙁

Screen Shot 2013-09-26 at 09.44.49

So I wrote a little script function that first get the VLAN information on the network adapters connected on the VM and then disconnects the virtual network adapters for the VM before migration and then the migration succeeds  🙂 and after the migration I connect the virtual network adapters to the VM networks on the new logic switch that correlates to the right VLAN from the source.

from a previous bad experience when trying to migrate VM´s between versions of Hyper-V on VMM with snapshots (Checkpoints) I added a check in the function to not allow migration of VM´s that have active snapshots.

Screen Shot 2013-09-26 at 14.28.54

And here is the script (will do some more thorough testing and add some functionallity but it gives you the idea )


Updated Add-SCNetworks function for virtual Networks in SCVMM 2012 SP1

Yesterday I described how I could get the networking info out from the VMM before a reinstall or if for another reason you need to get all networks defined.

In an earlier post I described my add networks script and now I have extended it a bit. I have this week made a function of it and also I have changed the import file format to fit the export-file as you get with the earlier post mentioned above. In the function I create a logic network if it is not already in place, that is also done for the network site in the logic network. The logic network created utilize VLAN.

So If you create or export a file with the following columns, Name, Subnet,VlanID you are going to success.

Screen Shot 2013-09-21 at 18.00.22

And when running the function:

Screen Shot 2013-09-21 at 18.05.13

One thing that I wanted also was the possibilty to create just one network with the script and that has also been added.

Screen Shot 2013-09-21 at 18.07.10

The function also handles if you already had setup a network with the same subnet and gives you a warning and do not create that net (maybe you accidentally try to add the same net twice and that is being handled)

Screen Shot 2013-09-21 at 18.11.55

Here is the function

# Add Networks to VMM 
# Niklas Åkerlund 2013-09-16
   Add networks to the logical network and creates virtual networks to them
   this function can take either a csv file as input for creating virtual networks
   Add-SCNetworks -importfile .\networks.csv
   Add-SCNetworks -Name DMZ -Subnet -VlanID 100 -VMHostGroup DMZHosts
Niklas Akerlund 2013-09-16
function Add-SCNetworks
        # Logical Network Name
        $LogicalNetworkName = "LumaNets",

        # Network site name
        # CSV file to be imported
        $ImportFile = " ",

        # Name of the VM network
        $VMHostGroup= "All Hosts"


        $LogicalNet = Get-SCLogicalNetwork -Name $LogicalNetworkName
        # If the logical network not exist, create it
            $logicalNet = New-SCLogicalNetwork -Name $LogicalNetworkName -LogicalNetworkDefinitionIsolation $true -EnableNetworkVirtualization $false -UseGRE $false -IsPVLAN $false
        Write-Verbose $LogicalNet.Name
        $LogicalNet = $LogicalNetwork

    $allSubnetVlan = @()

    # The networks that is going to be imported
    if ($ImportFile -ne " "){
        $vlans = import-csv $ImportFile -Delimiter ";"

        foreach ($vlan in $vlans) {
            # Check that the actual network not already is configured
            if(!((Get-SCLogicalNetworkDefinition).SubnetVLans.Subnet -contains $vlan.Subnet)){

                # First in fabric 
                $LogicalNetDef = Get-SCLogicalNetworkDefinition -LogicalNetwork $LogicalNet -Name $LogicalNetDefName
                $allSubnetVlan = $LogicalNetDef.SubnetVLans    
                $Subnet = $vlan.Subnet 
                Write-Verbose $Subnet
                $SubnetVlan = New-SCSubnetVLan -Subnet $Subnet -VLanID $vlan.VlanID
                $allSubnetVlan += $SubnetVLAN
                    Set-SCLogicalNetworkDefinition -LogicalNetworkDefinition $LogicalNetDef -SubnetVLan $allSubnetVlan
                }else {
                    $LogicalNetDef= New-SCLogicalNetworkDefinition -LogicalNetwork $LogicalNet -Name $LogicalNetDefName -SubnetVLan $allSubnetVlan -VMHostGroup $VMHostGroup

                # Then create VM Networks
                $vmNetwork = New-SCVMNetwork -Name $vlan.Name -LogicalNetwork $LogicalNet -IsolationType "VLANNetwork"
                #$vmSubnet = 
                New-SCVMSubnet -Name $vlan.Name -LogicalNetworkDefinition $LogicalNetDef -SubnetVLan $SubnetVLAN -VMNetwork $vmNetwork
                Write-Host "Subnet $Subnet already exists" -ForegroundColor Red
        # add only a single network
            if(!((Get-SCLogicalNetworkDefinition).SubnetVLans.Subnet -contains $Subnet)){
                # First in fabric 
                $LogicalNetDef = Get-SCLogicalNetworkDefinition -LogicalNetwork $LogicalNet -Name $LogicalNetDefName
                $allSubnetVlan = $LogicalNetDef.SubnetVLans    
                #$Subnet = $IPnet + $Octet
                Write-Verbose $Subnet
                $SubnetVlan = New-SCSubnetVLan -Subnet $Subnet -VLanID $vlanId
                $allSubnetVlan += $SubnetVLAN
                    Set-SCLogicalNetworkDefinition -LogicalNetworkDefinition $LogicalNetDef -SubnetVLan $allSubnetVlan
                }else {
                    New-SCLogicalNetworkDefinition -LogicalNetwork $LogicalNet -Name $LogicalNetDefName -SubnetVLan $allSubnetVlan -VMHostGroup $VMHostGroup

                # Then create VM Networks
                $vmNetwork = New-SCVMNetwork -Name $Name -LogicalNetwork $LogicalNet -IsolationType "VLANNetwork"
                #$vmSubnet = 
                New-SCVMSubnet -Name $Name -LogicalNetworkDefinition $LogicalNetDef -SubnetVLan $SubnetVLAN -VMNetwork $vmNetwork
                Write-Host "Subnet $Subnet already exists" -ForegroundColor Red

It works on both VMM 2012 SP1 and VMM 2012 R2 (preview)

I have looked at Alvin Morales latest blog post about creating networks and will see if I can add some more functionality into my code later on, I think that using parameters instead is a better way. There is always improvements that can be done and the only problem is the time 😉

Configure updates for Microsoft products in Windows Update

I have installed a new Windows 2012 Server for System Center VMM SP1 and when I wanted to check what updates that were applicable I found a small issue in the Windows Update and that when configuring it for receiving more updates than just for Windows. After installing the System Center Virtual Machine Manager I definitely want the UR3 for example and that is distributed via Windows update.

By default the setting is as the following screen dump, only Windows updates are being analysed and considered!

Screen Shot 2013-09-17 at 10.44.14


And when pressing the link “Find out more” I get a web page as the following and here you can see that the active-x plugin fails to load

Screen Shot 2013-09-17 at 10.47.11

So to fix this I add the url to trusted sites on IE

Screen Shot 2013-09-17 at 10.47.57

And now when I reload the web page I can agree to the terms of use

Screen Shot 2013-09-17 at 10.48.16

And once that is completed I now get updates for more than just Windows on my server 🙂

Screen Shot 2013-09-17 at 10.48.47

Adding multiple Windows hotfixes with wusa and PowerShell

Today I have been exploring a bit in patching  hyper-v hosts with windows updates and hotfixes and when we have a cluster we can use the CAU ( Cluster Aware Updating) that can help you in the process of getting those hotfixes on in a automated fashion but that does not work on single hosts..

In my blog post about checking the hosts for updates and hotfixes I also have added the functionality to download the hotfixes from Microsoft´s servers..

An easy way to add several hotfixes to a host is to use PowerShell with wusa (windows update standalone installer) and it eats .msu files gladly.

But wait, the hotfixes is in a self-extractor exe with at least for some no command-line way to automate, BAD!! So PowerShell to the rescue again, and here on this blog post I found a guy making a PS function to unzip an archive file and it works on the hotfix.EXE also!

Screen Shot 2013-09-13 at 20.18.45
Get-Item .\* | %{Expand-ZipFile -FilePath $_.FullName -OutputPath c:\hotfixes}

And then we can use the WUSA and that wrapped in a foreach with a little while loop to handle that not a  new wusa starts before the preceding one is done as it cannot be run several instances simultaneously (maybe there is a better way to do this of course but this works 😉 )

Screen Shot 2013-09-13 at 14.38.17
Get-Item c:\hotfixes\* | foreach {WUSA ""$_.FullName /quiet /norestart"";while(get-process wusa){Write-Host "Installing $_.Name"}}

And to see if your hotfixes has been installed you can use the following command

Get-HotFix | Where Description -match hotfix

(Get-HotFix | Where Description -match hotfix).count

and of course after installing the hotfixes we need to reboot 🙂

Live Migrate VM from Windows 2012 to Windows 2012 R2 RTM

Today Microsoft announced the availability of Windows 2012 R2 RTM to Technet/MSDN subscribers.

As I have a Technet subscription with my MCT I had to download right away install and see if it works….

Screen Shot 2013-09-09 at 19.50.16

When I had installed the server I activated the Hyper-V role and the management tools

Screen Shot 2013-09-09 at 19.51.09

In the RTM version of the Hyper-V PowerShell module there is 178 cmdlets and in the preview it was the same number so no new cmdlets have appeared in the latest release.

Screen Shot 2013-09-09 at 20.36.18

I had to test the Live Migration feature and see if it worked to move a VM from a win 2012 Hyper-V to a R2 RTM, I had some issues when trying from the R2 ( I had done the delegation in the AD for kerberos) and when trying from the hyper-v manager it was not totally clear what was wrong:

Screen Shot 2013-09-09 at 21.06.35


and it was in the PowerShell console the error was stated  and as you can see I had forgot to set up a virtual network with the same name as on the source host and that was why the migration failed..

Screen Shot 2013-09-09 at 21.11.42

once that was done the migration worked flawlessly 🙂

Screen Shot 2013-09-09 at 21.16.59

Tomorrow I will continue evaluate the RTM release and maybe there will be a new post about my findings then  🙂


Azure and uploading OS VHD´s larger than 127 GB

I have been busy with a newborn baby and not had so much time over for my blog but now I am back at work 🙂

I was reading this post about how to convert the vhdx to vhd before uploading your virtual disks to Azure and felt that I needed to explore why the default OS vhd disks on the IaaS role is 127 GB and not larger. There was once a limit that Virtual PC could not utilize larger disks than 127GB on the IDE controller but do not think that Azure runs on Virtual PC 😉

In your local cloud and Hyper-V 2012 you can create VM´s with OS disks connected to the IDE that is larger than 127 GB, although the best practice is to create additional disks and connect them to the SCSI controller instead and install the services there!

So to test first that i could convert a vhdx to vhd and then upload it, and also be able to use it in Azure I used the Convert-WindowsImage.ps1 script to create my test-vm that was 128GB large.

Screen Shot 2013-09-09 at 16.06.56

When uploading with the cmdlet from the Azure PowerShell module it goes quite fast as it only uploads the bits that contains data, not empty blocks.

Screen Shot 2013-09-09 at 15.07.44

And when the upload is finished you create a disk from the uploaded VHD, and as you can see on the screendump it is still 128 GB

Screen Shot 2013-09-09 at 15.16.18

and when I start and connect to it, it show the disk size of 128 GB inside the IaaS VM also!

Screen Shot 2013-09-09 at 15.35.26

One lesson learned is that before uploading your own virtual machine VHD to Azure, and that is to enable remote desktop settings as otherwise you will not be able to connect to the Azure virtual machine once it is running.

Screen Shot 2013-09-09 at 15.53.06


Shrinking the C: System VHD disk in Azure IaaS

Today I have been working with Azure and the disk size. In our lab environment we started out when the Azure Iaas role was still in preview and it had a limit that not until now have appeared as a problem. The system VHD in the preview version was only 30 GB and now when the c:\windows\winSxS folder has grown with patches and install files to about 14 GB the volume is beyond full :-/ and yes the SQL service running on the server is installed on another partition..

And as you can read on this blog post it is not an option to try to remove the files inside the winSxS folder!

The different options on how to do an resize of an disk in an Azure Iaas VM when doing a search is quite cumbersome but I found this guy Maarten Balliauw that made a console app that can fix the stuff and this without installing new VM´s or downloading the VHD.

Now to test how to do it I created a new VM and this get a OS disk with 127 GB and I wanted it to be 30 GB so I had to shrink it. The binary that Maarten have does not include the latest addition with the shrink option, so I asked my colleague to compile it for me as I do not have Visual Studio installed (at least not yet), Thank you Tim!

UPDATE -> Download Tims compiled binary here : shrinkAzure

So to do a shrink with the latest source and a friend with a compiler.

  • Shrink the partition with powershell or disk management tool (if you do not the OS partition will be corrupt if shrink the vhd beyond this)
  • Shutdown the VM
  • Delete the VM -or- detach the disk if it’s not the OS disk
  • Delete the cloud service if you have created it to be able to create a new with the same name
  • In the Windows Azure portal, delete the disk (retain the data!) do that the lease Windows Azure has on it is removed
  • Run WindowsAzureDiskResizer
  • In the Windows Azure portal, recreate the disk based on the existing blob
  • Recreate the VM  -or- reattach the disk if it’s not the OS disk
  • Start the VM

So I start shrinking the volume inside the Azure VM. As you might notice I have shrink it to just below 30 GB (30GB -1MB)

Screen Shot 2013-08-21 at 14.42.25

And then I have a volume that looks like this in the disk manager

Screen Shot 2013-08-21 at 14.43.05

Next step is to delete the VM and also the delete the disk (retain data) and as Maarten says I can then use his tool, if I do not delete the disk from the Iaas it will fail. And here I enter 30 GB disk size, and if I would not have done the volume just 1 MB below 30GB I get a corrupt OS volume, the tool does not check the volumes inside the VHD..

Of course I could have done a VHD size of 31 GB but this was just for testing and seeing what happens.. I did also remove the Cloud Service so that I could use that name after I was done to get the old url to the new VM.

Screen Shot 2013-08-21 at 14.52.50

Now it is time to re-create the virtual disk and then the virtual machine..

Screen Shot 2013-08-21 at 14.54.07

And then when I started the virtual machine and connect to it, the size of the disk is 30 GB

Screen Shot 2013-08-21 at 15.05.58

I am looking forward to the day that Azure runs on Windows 2012 R2 Hyper-V and the VM´s in the Iaas role can be configured with Gen2 and you can change the vhdx size on the fly when the VM is running 🙂