Managing Hyper-V 2012 with Win 2008 R2/7 RSAT tools

I have noticed several forum posts about some issues managing the Windows 2012 Hyper-V or the free Hyper-V 2012 Server.

Most of the cases are because people try to use the Hyper-V manager in Windows 2008 R2 or the Hyper-V manager from the RSAT tools in Windows 7.

As you can see on this screendump, you can successfully connect to a 2012 Hyper-V from a Win7 Hyper-V manager. But the features offered in the new Hyper-V is not accessible in this GUI, this causes some confusion when handling the VM´s and the Hyper-V role!

Screen Shot 2013-02-09 at 12.18.02

And here you can see that the server HV03 really is a 2012 version:

Screen Shot 2013-02-09 at 12.49.21

So for example, when you are going to edit the VM and add a new virtual harddisk you will notice that the new VHDX is not available

Screen Shot 2013-02-09 at 13.05.09

And as you can see in the following screendump from a new Hyper-V manager:

Screen Shot 2013-02-09 at 13.04.27

Some things work though, you can set more memory than the Windows 2008 R2 limit and also set more than 4 vCPU´s!

Screen Shot 2013-02-09 at 13.13.43

The ability to setup Hyper-V replica and to move VM´s are absent from the GUI as these are new features.

Yes It works to manage some stuff in the old Hyper-V manager but not all so my recommendation as it is not supported you should install a Windows 2012 or a Windows 8 to manage your new Hyper-V 2012 and also more importanly you will get the powershell module to manage it!

I have made a blog post about how to enable the Hyper-V manager and the Powershell module on the Windows 2012 and Windows 8!

Find correlation between vmwp process and VM in Hyper-V 2012

If you by some reason need to kill the process that is handling the VM in Hyper-V which is the Virtual Machine Worker Process, it can be handy to also know what vmwp process that correlates to what VM 😛 or you could accidently restart the wrong VM. Restarting the VM is the default behavior when the process dies.

If you look in the task manager of the Parent Partition you can see the processes.

Screen Shot 2013-01-30 at 13.00.08

If you look a bit deeper into the task manager you can see that each process in the command line have the virtual machine ID and then digging into this with PowerShell you can find out what VMWP process each VM has. I have been trying to use the Get-Process Cmdlet but that left me with no luck, then I found this post by Ravikanth that uses the Get-WmiObject instead, so I used that and altered what process to get.

Screen Shot 2013-01-30 at 16.17.02

I have made a oneliner that does this and as you can see on the following screendump I get a list of the VM´s and the Process Id´s.

Screen Shot 2013-01-30 at 16.24.39
Get-WmiObject Win32_Process -Filter "Name like '%vmwp%'" | Select-Object ProcessId, @{Label="VMName";Expression = {(Get-VM -Id $_.Commandline.split(" ")[1] | Select-Object VMName).VMName}} | ft -AutoSize

Remote management of Windows 2012 Hyper-V Powershell Dism failure

Last week on the NIC keynote we could hear Jeffrey Snover talk about Windows 2012 and also that the preferred version when installing is Core, but then you will not have the Hyper-V manager locally (yes you could use the PowerShell module….).

Screen Shot 2013-01-24 at 13.09.14

So how do we enable our management station for remote Hyper-V tasks…

If you have a Windows 2012 you can easily just enable the Remote Server Administration Tools for Hyper-V and that preferably with PowerShell

Screen Shot 2013-01-29 at 21.09.24

And if you want to check if you have the Hyper-V management features installed you can use the Get-WindowsFeature

Screen Shot 2013-01-29 at 21.09.51

I usually also add the Failover cluster RSAT feature also to be able to manage the cluster.

Add-WindowsFeature RSAT-Hyper-V-Tools -IncludeAllSubFeature
Add-WindowsFeature RSAT-Clustering -IncludeAllSubFeature

If you want to add the Hyper-V tools in a Windows 8 you would guess that you have to use the DISM tools and there are some DISM cmdlets, You might have noticed that the Hyper-V tools are not part of the RSAT package for windows 8 this as the client Hyper-V role is part of the OS. But either I am doing something wrong or someone in Redmond has not thought this part through regarding the enabling of features in PowerShell for Win8!

because when I try the following Cmdlet with parameters

Screen Shot 2013-01-29 at 22.16.09
Enable-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-Tools-All

The PowerShell console barf out an error because when trying to add the Management tools with the powershell cmdlet I get info that it needs a parent feature which would be the Hyper-V feature and in this virtual windows 8 client that is not what I want,

When using the Control Panel, Add/Remove software/Windows Features you can add the Hyper-V Management tools in your Windows 8 without adding the Hyper-V Platform!

Screen Shot 2013-01-29 at 16.29.23

I will pursue this with some smart PowerShell gurus and see if they have an answer to why this happens 🙂

In the meantime good luck in creating your management pc!

 

Upgraded from SC 2012 SP1 Beta/CTP to SP1 RTM

I have today tested to upgrade the Beta/CTP version of SC 2012 SP1 to the newly released SP1 RTM version for

  • SC Orchestrator
  • SC Virtual Machine Manager
  • SC Operations Manager (Community Technology Preview)

As the articles on technet tells you it is not supported but I wanted to try and see how I could do it in my lab environment and what consequences it would have . I have one DC Server, one VMM/ORCH/SCOM server (maybe not best practice to have all three roles on the same server but it works 😀 ) and one Hyper-V host with some lab-VM´s

I started with the Orchestrator and when I connected the ISO to the server/servers and try to install I got an dialog that I already have it installed, but it is the wrong version so I have to uninstall everything first, So did that and then during the installation selected the old DB in the wizard and after that I could see all my runbooks and IP´s still are there.

Screen Shot 2013-01-22 at 16.32.16

Then It was time for the SC VMM, but now the installation guide clearly told me that I had to uninstall the product, although as you can read on the screen dump: if I am running SC 2012 I can retain the database when uninstalling.

Screen Shot 2013-01-22 at 14.05.14

In the uninstall wizard, be sure to check this box:

Screen Shot 2013-01-22 at 14.10.51

And then during the new installation be sure to point out the old database

Screen Shot 2013-01-22 at 14.14.02

The installation wizard will then check and ask if you want to upgrade it, pretty nice and for not supporting an upgrade they have made it quite easy to do it anyway!

Screen Shot 2013-01-22 at 14.14.19

Also, the wizard recognizes the library share that I had configured before. In the last step I get an summary that tells me what potential issues might occur with this upgrade, As you can read in the first part it is important to use the same server as the vmm was installed on before and that you use the same service account for VMM this for the Run-As accounts to work!

Screen Shot 2013-01-22 at 14.17.29

When the installation is complete I had to update the Agent on the Hyper-V host.

Screen Shot 2013-01-22 at 14.25.07

After this I continued to upgrade the SCOM, when starting the installation wizard I did not need to uninstall anything and right away the SCOM accepted an upgrade to the RTM version.

Screen Shot 2013-01-22 at 15.01.04

After successfully “upgrading” these components there are some more work that needs to be done, such as the SCOM-SCVMM integration that need upgrading and also Orchestrator IP that should be taken care of but that in another blog post 🙂

Getting files out of a running VM in Hyper-V 2012 remotely

I was reading the post by Ben Virtual-PC Guy about how to get files out of a running virtual machine.

I have altered his bits to work also when not running on a Hyper-V host (as Mount-VHD does not work when not Hyper-V is enabled), and you have the VM´s on a smb share, this also works if you take a snapshot and then copy the vhdx file to a windows 8 or windows 2012 machine.

The cool part is that I can use a UNC share path with Mount-DiskImage which is the Cmdlet used.

If I have the right permissions I can then easily with just a PowerShell script as Ben showed mount the virtual harddisk and copy the files, and this from a remote server and not on the Hyper-V host.

Screen Shot 2013-01-09 at 23.28.25
Get-VM core -ComputerName hv01 | Checkpoint-VM -SnapshotName "Need to look at these disks" -Passthru | %{Get-VHD -VMId $_.vmid -ComputerName $_.ComputerName} | %{Mount-DiskImage -ImagePath $_.ParentPath -Access ReadOnly -PassThru}

After I have run this you see that I can then get the secret file out of the running virtual machine

Screen Shot 2013-01-09 at 16.35.22

and when I am finished copying the secret files from the running virtual machine I can unmount the disk and remove the snapshot.

 

Screen Shot 2013-01-09 at 23.29.26
PS C:\> Get-VM Core -ComputerName HV01 | Get-VMSnapshot | %{Get-VHD -VMId $_.vmid -ComputerName $_.ComputerName; Remove-VMSnapshot -VMName $_.VMName -ComputerName $_.ComputerName} | %{Dismount-DiskImage $_.ParentPath -PassThru}

So what is the conclusion on this in a security perspective, as you can see it is quite easy for a person with the right permissions on a host level to get access of files that he or she maybe not should see. Talented hackers can get permissions and accounts that they need. This leads to the discussion of course where you should put your hosts, is it enough security and boundaries on your network and in your Active Directory Domain or should you set up another for the Hyper-V hosts and management servers?!

Bug in Powershell v3 on regional settings in Windows 2012

In my previos post I was claiming that there was a bug in the Get-WinEvent, but the bug is in Powershell v3 and how it works with the regional settings.

I live in Sweden and thus have Sweden as regional format setting and that did Powershell version 3 not like, at least not for the Get-WinEvent cmdlet 😛

Screen Shot 2013-01-09 at 14.02.22

Using powershell to change the format or culture is done with the following

Screen Shot 2013-01-09 at 14.05.06
Get-Culture
Set-Culture en-US
Screen Shot 2013-01-09 at 14.13.54

And when I open a new PowerShell Console I can see the messages for my Hyper-V events 🙂 not so good with the bug though..

Screen Shot 2013-01-09 at 14.18.58

Lets hope there is a bug fix soon, a bit embarrassing when some parts of the powershell console is not working in other regional settings besides en-US, are we in other parts of the world not that important or just an mistake by an developer, lets hope for the later..

A big thanks to Andreas Hultgren that was first to let me know about the bug 🙂

Bug in Get-WinEvent on Windows 2012?

I have been trying to get some Events out of my test environment for some Hyper-V stuff.

What I have noticed when digging down into the Get-EventLog and Get-WinEvent I get different information

The Get-EventLog gives me information and message about the Windows Logs and there it works nicely as you can see

Screen Shot 2013-01-09 at 12.14.07

But when I try to get information from as in this case Hyper-V logs with Get-WinEvent I get no information in the fields LevelDisplayName and Messages?!

Screen Shot 2013-01-09 at 12.21.57

And in the Event Viewer you can see that the information is there:

Screen Shot 2013-01-09 at 12.27.14

Have I misunderstood something how to get the Events in PowerShell or is there a bug in the system? In the old “Windows 2008 R2” I got the information correctly as you can see on this screendump, so the Get-WinEvent issue is related to Win 2012 version!

 

Screen Shot 2013-01-09 at 12.40.54

It kind of sucks if I cannot search the messages for some data and collect that information, and what I can see it seems to be the same case for all application and services logs and I will not accept to have to go the Event Viewer GUI 🙂

 

Schedule Hyper-V VM replication for non-office hours with PowerShell

If you have set up Hyper-V replica and are replicating your VM´s to a disaster site or maybe a branch office and that office might have a small WAN connection to the datacenter and you cannot get a faster connection from the ISP and for example you might want to stop the replication during the office hours and resume it on the night you can use the new Powershell version 3 feature scheduled jobs.

This will of course imply on your recovery when there was a disaster. But this can be compared to having an offsite DPM server that you sync to every 24 hours.

Anyway, if you want, you can enable a scheduled job that suspends and resumes a VM replication. I created earlier a blog post about setting up scheduled jobs. The following Cmdlets am I using in this case:

  • Suspend-VMReplication
  • Resume-VMReplication

A simple example, I have a VM that I am currently replicating and want it to be suspended during the day and then resumed when all my users have gone home and I have all bandwidth again.

First I add a replication receiver host for my replicated servers

PS C:\> Set-VMReplicationServer -ComputerName HV02 -ReplicationEnabled $true -AllowedAuthenticationType Kerberos -ReplicationAllowedFromAnyServer $true -DefaultStorageLocation c:\VMs

And then I need to set up the VM replication

PS C:\> Enable-VMReplication -VMName Brun12 -ReplicaServerName HV02.vniklas.com -ReplicaServerPort 80 -AuthenticationType Kerberos -ComputerName HV01.vniklas.com

PS C:\> Start-VMInitialReplication -VMName brun12 -ComputerName HV01

So How do I schedule then, as you can see on my screendumps, I have used other times for my scheduled jobs than you might want in your environment, you can also use other parameters than -Daily . Use Get-Help New-JobTrigger -full to get the help and there you can see all the options

PS C:\> $cred = Get-Credential

PS C:\> $dailystop = New-JobTrigger -Daily -At 14:10
PS C:\> Register-ScheduledJob -Name StopRepl -ScriptBlock { Suspend-VMReplication -VMName Brun12 -ComputerName HV01 } -Trigger $dailystop -Credential $cred

PS C:\> $dailystart = New-JobTrigger -Daily -At 14:15
PS C:\> Register-ScheduledJob -Name StartRepl -ScriptBlock { Resume-VMReplication -VMName Brun12 -Resynchronize -ComputerName HV01 } -Trigger $dailystart -Credential $cred

And here on this screendump you can see that it works,

Another minor detail, If you have a VM that changes lot of data on the virtual disks during the day, it will take a while for the resyncing after a longer suspension.

Installing SC Orchestrator 2012 SP1

Today I have been exploring the SC Orchestrator and its functionality with Hyper-V 2012 and SC VMM 2o12 SP1. First of all to get it installed I had to run the installations in “run-as” otherwise it failed during the wizard. I installed it on a Windows 2012, and one prerequisite is that you have the .net 3.5 installed also.

One annoying thing is when you add Integration Packs, unlike for example Operations Manager and importing management packs, you can only add one IP at a time when importing.. And if you want to add like 10-20 first time it is a bit tedious! Please fix that in the RTM.

Another thing that I encountered was an error I did not first understand. When I had added the SCVMM 2012 SP1 IP and wanted to use it, I first added some configuration data but apparently it was not enough cause when I tried to use it I got an error

So what was the error, I had not entered the VMM Console information in the following configuration dialog and apparently the IP uses Powershell under the hood and connects to the powershell console with the vmm module.

When that was configured correctly I could continue to create my first runbook, look at this link to get some SCORCH examples (really handy to get the idea of how to use it and that in runbook examples to have in your Orchestrator designer)

Here is an easy example, I enter a VM name and if the state is “Running” I stop it, and if the state is Stopped I start the VM:

I have been using Powershell quite a bit and not looking so much at the Orchestrator but it is really easy to get up and creating your runbooks. Try it out and see for yourselves.

Some PowerShell and Windows Hyper-V 2012, find VM´s not connected

Digging around in the powershell module for Hyper-V have given me some ideas on what you can do.

Have you ever wondered about if you have a VM that is not connected to any network?

First you use the script part I showed in an earlier post, how to find Hyper-V servers in your AD :

$VMhosts = Get-ADObject -Filter 'Name -like "*Hyper-V"' | %{$_.DistinguishedName.Split(",")[1].replace("CN=","") }

And then you can run the following to list all VM´s that are not connected to any virtual network

$VMhosts | %{ Get-VM -ComputerName $_ | Get-VMNetworkAdapter | where SwitchName -eq $null}

In this little screendump you can see for all my Hyper-V hosts what VM´s without a network connection, you can also easily change the -eq $null to a switch name and then get what VM´s are connected to that particular virtual switch on all your hosts

good luck 🙂