Archive

Archive for the ‘Powershell’ Category

New version of the Microsoft Virtual Machine Converter 2.0 and MAT

April 8th, 2014 No comments

Today Microsoft released the long awaited new version of the Virtual Machine Converter (the 1.0 version could be integrated with MAT but had limits in both VMware and Hyper-V latest releases). Microsoft has also released a new version of the MAT (migration automation toolkit) that supports the MVMC 2.0 to automate the migration!

Screen Shot 2014-04-08 at 19.20.57

New Features in MVMC 2.0

MVMC 2.0 release of MVMC includes the following new features:

    • Converts virtual disks that are attached to a VMware virtual machine to virtual hard disks (VHDs) that can be uploaded to Windows Azure.
    • Provides native Windows PowerShell capability that enables scripting and integration into IT automation workflows.
      Note The command-line interface (CLI) in MVMC 1.0 has been replaced by Windows PowerShell in MVMC 2.0.
    • Supports conversion and provisioning of Linux-based guest operating systems from VMware hosts to Hyper-V hosts.
    • Supports conversion of offline virtual machines.
    • Supports the new virtual hard disk format (VHDX) when converting and provisioning in Hyper-V in Windows Server® 2012 R2 and Windows Server 2012.
    • Supports conversion of virtual machines from VMware vSphere 5.5, VMware vSphere 5.1, and VMware vSphere 4.1 hosts Hyper-V virtual machines.
    • Supports Windows Server® 2012 R2, Windows Server® 2012, and Windows® 8 as guest operating systems that you can select for conversion

in the link you can read more about the MVMC functionality

As you can see in the wizard the option to upload the converted VM to Azure directly has been added

Screen Shot 2014-04-08 at 19.21.50

And now in this version we have native PowerShell with the MVMC PS module as described above:

Screen Shot 2014-04-08 at 20.05.11

I will show more in a later post how it can be used and how it works with both migrations to Hyper-V and also directly to Azure :-)

both MVMC and MAT can be read about and downloaded here

Categories: Azure, Hyper-V, Powershell, Virtualization, VMware Tags:

Automated PowerShell to keep your template vhd(x) IC updated

March 31st, 2014 No comments

For the Veeam Seminar I did some digging in how to check and also apply updated integrational components on virtual disks in the System Center VMM library and found Ben´s script which I altered to fit my goal. This is quite convenient based on that you can schedule it and always have updated IC´s on those VHDX in the library.

I check and get the current IC´s from one Hyper-V host and thus based on that if it has been updated I also get that update instead of using a copied IC version locally in the VMM server. The script runs on the VMM server and that is why I use the Mount-DiskImage cmdlet instead of the Mount-VHD as that does not work on a non-hyper-V enabled windows server.

Screen Shot 2014-03-30 at 10.42.33

 

 

 

Recordings and code from SMA and Powershell webinar with Veeam

March 29th, 2014 No comments

Last week I had two webinars together with Veeam in the subject of “Automating daunting virtualization tasks”. Now these have been uploaded and shared on Veeams web. One is in swedish and one in english. during the webinar I show some different tasks that can be managed and handled with the Service Management Automation (SMA) and utilizing PowerShell.

51075482-98cb-11e3-82f1-12313b12ccaf-large

here is the english version: http://www.veeam.com/videos/webinar-replay-service-management-automation-akerlund-en-3932.html

and here is the swedish version: http://www.veeam.com/videos/webinar-replay-service-management-automation-akerlund-sw-3649.html

Here are some of the tasks and the PowerShell code,

First one of the tasks was adding VM´s to cluster where I utilize the function in this link

Next task that can be automated that you always will have a percentage free on the C drive for the VM´s (it both shrinks and expands), I am utilizing the generation 2 VM´s so for this to work your VM´s have to be configured with this latest virtual hardware version on Hyper-V 2012 R2

As you can see when I extend the size I make the VHDx about 230 MB larger to be able to set the partition to the size calculated regarding the overhead of the virtual disk, so if I would have tried to make both the VHDx and partition 15GB it would fail..

The rest of the scripts will be uploaded later in a follow up post. Of course there can be improvements in the ways to do things and if you have any comments or ideas please share :-)

 

Updated Raiders of the lost Cluster VM´s PowerShell function

March 17th, 2014 No comments

In 2012 I did a blogpost about a PowerShell function to find VM´s on Hyper-V Cluster nodes that was not configured as cluster resources and thus not being Highly Available in case of a hardware failure or maintenance work on the Hyper-V hosts…

687883034_1836208864001_raiders-of-the-lost-ark-imax-trailer-still

I have today made an update to the function so that it only gives the VM´s that have either SMB or CSV storage and not if you for some reason have VM´s residing on local storage within your clusternodes which can be the case for domain controllers or other appliances etc..

Good luck in your raid for the Lost Ark ;-)

Categories: Hyper-V, Powershell, Virtualization Tags:

Veeam webinar 19/3: Automate daunting virtualization tasks with SMA

March 5th, 2014 No comments

On wednesday the 19th of March I will together with Veeam have a web seminar with the topic:

Screen Shot 2014-03-05 at 21.54.12

Automate daunting virtualization tasks  with SMA

Now that you have set up your virtualization environment, you’ll want to automate it. In this webinar, you will learn how to do this with Service Management Automation(SMA) and how to integrate automated tasks into the Hyper-V virtualization environment. You will use different runbooks to automate some boring but necessary tasks that IT admins have to do.

This webinar will show you how to:

  • Automate patching of virtualization hosts
  • Expand virtual hard disks based on usage
  • Automatically update integrational components on VMs
  • Automatically update virtual hard disk templates
  • Clean old snapshots that have been forgotten
  • And more…

If you want to register and be part of this crazy one hour with the Swedish Chef you can do it on the following link

And guess what, It comes in a swedish version also! Check out in the following link and if you understand Swedish, register here!

Why are my Hyper-V hosts in VMM reporting “Needs Attention”?

February 27th, 2014 No comments

If you are kind of new to System Center VMM console and wondering why after a while your hosts responds “Needs Attention” and checking the host properties and seeing that everything looks green in the status, then continue and read this post!

Screen Shot 2014-02-27 at 10.18.10

Screen Shot 2014-02-27 at 12.31.28

You can just extend the console by right-click the hosts bar and add the column with “Agent Version Status” and then you can see the reason for host status,

Screen Shot 2014-02-27 at 10.23.49

The reason for this “Upgrade Avail” is that the VMM server has been updated with some new patches/updates that came with Windows Update and now you need to update your hosts to have the new agent to properly talk to the VMM Server.

That can of course be done with PowerShell if you have quite some hosts…  You can of course also get the list of which hosts that need an update,

Screen Shot 2014-02-27 at 10.41.28

And then with the following command also update the hosts that need to

Screen Shot 2014-02-27 at 10.53.23

If you are wondering why I am filtering on Agent-Version -ne “0.0″ is because in this environment there are several VMware hosts and they do not have a VMM agent but is recognised as managed hosts and appear when getting the “managed computers”

Good luck :-)

Categories: Hyper-V, Powershell, SCVMM, SysCtr, Virtualization Tags:

SCVMM VM property dialog crash console with missing vhd(x)

January 14th, 2014 No comments

Today I was at a customer and they had an interesting error in their virtualization environment with Hyper-V 2012 and SC VMM 2012 Sp1 (yes I know, it is not R2 but we are working on it). One of their Hyper-V hosts had a hardware memory failure which lead to the host crashing and the VM´s restarting on other hosts..

during this the VM´s that was on that host got an error in the VMM db, looking and handling the VM´s from Hyper-V manager or failover cluster manager was no problem. Every time we tried to refresh the VM´s showed the following error and the job did not succeed.

Screen Shot 2014-01-14 at 14.36.51

And when we tried to look at the properties on the VM from VMM the console just died, and that happened every time..

Screen Shot 2014-01-14 at 14.28.50

So how could we find the VM´s that was suffering from this, well PowerShell could be used and with the following we could get the amount of VM´s and also easily get a list of the VM´s names.

Screen Shot 2014-01-14 at 13.26.15

So how could we fix this then,

There is a cmdlet in VMM with a parameter that can be used,  Remove-SCVirtualMachine -Force , this will remove the VM but not the virtual hard disk as it cannot find it..

Screen Shot 2014-01-14 at 16.20.21

But because we want to keep the VM we will do a bit of a workaround

  1. Stop the vm in VMM  by Stop-SCVirtualMachine own01  (even if the vhd(x) is not seen by VMM it will shut down the actual VM)
  2. Remove the VM from the cluster in Failover cluster manager or with powershell (this will only remove the cluster instance but not the actual VM)
  3. Start the VM in Hyper-V manager or with PowerShell  Get-VM own01 -ComputerName HV01 | Start-VM
  4. Remove the VM from the VMM with Powershell using the -force  Get-SCVirtualMachine own01 | Remove-SCVirtualMachine -Force (as I have removed the VM from the cluster VMM cannot find it and delete the vm´s xml file etc)
  5. Add the running VM to the cluster again with hyper-V PowerShell and failover cluster powershell using Get-VM own01 -ComputerName HV01 | Add-VMToCluster (Get-Cluster HVCL30)
  6. refresh VM´s in VMM and see that now the own01 vm can open properties

The reason I start the VM after removing it from the failover cluster is that VMM should think it is in stopped state, because that makes it easier to remove! And as in Hyper-V 2012 I can add a running VM to a cluster I do not have to keep the VM shut down during the whole process but just to get it into the right state in VMM :-)

Not the easiest way but hey who had said that VMM was self-healing :-P And yes we are in the process of upgrading to R2 and hopefully this error will not reemerge in that version….

 

New version of Convert-WindowsImage.ps1 that support Gen2

December 30th, 2013 No comments

So I noticed that the awesome Convert-WindowsImage.ps1 PowerShell script has been updated to version 6.3 and published during the Christmas holidays. The script is maintained by Microsoft Consulting Services and was originally created by Mike Kolitz.

I really like this script and have used it alot when creating new VM´s and I have been awaiting an update to support the Generation 2 VM´s with UEFI boot.

Here you can see that I have added the parameter -VHDPartitionStyle GPT to use for the generation 2 VM

Screen Shot 2013-12-30 at 21.59.28

You can find the script here.

 

Categories: Hyper-V, Powershell, Virtualization, Win2012 Tags:

Convert to generation 2 on a VM in Hyper-V 2012 R2 with Powershell

October 30th, 2013 No comments

I have done blog posts about why you should create your new VM´s with Windows Server 2012 instead of 2008 R2 or older even if you were not able to create them with the generation 2 at that time as the Windows 2012 R2 was not released back then.

I also did a blog post how to use a third party product to do the migration from generation 1 to 2 with Double Take Move software.

Now I found John Howards script that he has made public that does the migration from generation 1 to 2 :-) He also has a blog series about generation 2 VM´s that is definitely worth the time to check out.

I got an error when running it though and it seems that it does not work so good with the partition on the gen 1 virtual disk..  It appears that when I have created my virtual machine with the Convert-WindowsImage.ps1 script that only creates one partition the row in the script that checks for $partitions.length fails and I could not get it to continue but when I commented that away I got my first conversion on the way :-)

Screen Shot 2013-10-30 at 20.40.59

And here you can se in the PowerShell ISE my alteration  :-)

Screen Shot 2013-10-30 at 22.15.58

Now I am sure that John and his team will work and distribute new versions with correct error checking and I am truly glad that they have released this so I could test it right now anyway :-) !!

Here is my VM in generation 1

Screen Shot 2013-10-30 at 21.50.07

And here is the converted VM,

Screen Shot 2013-10-30 at 22.21.34

And here you can see that during the conversion that I have two disks attached to my server and that the one at the bottom has got some new partitions for the gen 2 UEFI boot process

Screen Shot 2013-10-30 at 22.15.03

Happy converting and making generation 2 VM´s your standard in Hyper-V

Categories: Hyper-V, Powershell, Virtualization, Win2012 Tags:

Updated download script for evaluation VHD for SysCtr 2012 R2

October 23rd, 2013 No comments

Now when the evaluation VHD´s have been updated with the release of the System Center R2 that was released last week I have updated my download script so you easily can get all the files at a convenient place with PowerShell and the BITS engine.

Good luck in your evaluation of the System Center 2012 R2 suite :-)

 

Categories: Powershell, SysCtr Tags: