Monday, April 2, 2012

Windows Server "8" with Hyper-V and Powershell

I`m just about to get my hands on my SAN to be able to do some cool things covering both the SC 2012 suite (Private Cloud scenarios) and Windows Server “8” with Hyper-V.
I need access to both environments since I`ll deal a lot with both of them in different scenarios, like proof of concept, demos and researching. Sounds fun? – it is!

Below is a very simple overview of my environment, showing you that I have 2 clusters in a single domain. 1 Windows Server “8” Hyper-V cluster and 1 Windows Server 2008 R2 Sp1 Hyper-V Cluster with the current SC 2012 components installed and orchestrating the magic.

To run a SAN, I`ll use Windows Server “8” with the inbuilt iSCSI target, and i`m looking forward to test and play with Storage Pools and Storage Spaces.

So what have I done to this point, with no SAN for my VMs? People who know me also know that I`m addicted to clusters. I need them in my life. But the life has treated me good because I`ve been running Windows Server “8” directly on my laptop.

There are several reasons for this. Here`s a couple of them.

1.       Kristian, you better start learning Powershell. No discussion. Do it.

2.       Do all the possible research related to Hyper-V, and especially by using Powershell.

3.       Remember to learn well, since this will be your bread and butter.

So, let`s talk a bit about Powershell in this blog post.

Several top dogs at Microsoft have stressed that it is extremely important for the technologist to be able to manage things through Powershell. And if you see this in the cloud context where as much as possible should be considered for automation, powershell is the key since the robust API towards SC 2012 and Windows Server “8” would be …. Powershell!

So here`s some handy Powershell cmdlets that I have been using the last days.

(Note, this is not rocket science but it`s very handy)

Start all your VMs

Get-VM * | start-VM

Shut down all your VMs

Get-VM * | stop-VM

Move storage

Move-VMStorage “VM name” “Destination” (Example: Move-VMStorage “SCOM2012” “E:\VHDs\SCOM2012”

Enable Dyanmic Memory on every VM

Get-VM * | set-VMMemory –Dynamicmemoryenabled $true –startupbytes 512MB –minimumbytes 100MB –maximumbytes 6GB

(Thanks to Aidan Finn)

Clean up your environment after some heavy Storage Migration demos

Get-VM | % { Move-VMStorage $_.Name “E:\VMs\$($_.Name)” }

(Thanks to Benjamin Armstrong)

And of course, there`s a lot of new cmdlets related to the Hyper-V Role.

To get an overview, type:

Get-commands –module Hyper-V

This will list all the cmdlets for you. You can also play around and use Powershell ISE tool to help you to build, test, and evaluate scripts that you create by using Powershell.

Oh, I have created some scripts as well, but I`ll save them for later in another blog post.

So my next step would be to move all my VMs with SC 2012 installed from my laptop over to the newly created lab. I will show the examples of how this was done in another blog post later.


No comments: