Windows 8 Client Hyper-V and exchanging files with PowerShell

Ben the Virtual PC Guy did a blog post a while ago where he showed how to get files out of a running machine, and I made a follow up where using a non Hyper-V host to get the files.

Today I read on a forum that they where discussing how to get a folder and the files from a virtual machine running on Windows 8 client Hyper-V by enabling and fiddeling with the network. In some cases you do not want to enable networking on that guest to the Win8 host and then you can use the way that Ben showed.

Or you can use an VHD that you first connect to the Win8 host and then copy the files and when you are done you can disconnect it from the host machine and connect it to the virtual machine, with this approach instead of the snapshot you can also add files from the host to the virtual machine and the other way around.

So With PowerShell I first create an VHD and mount it to the Host, create a partition and format it and then I copy the data I want to transfer and then also mount it to the VM.

Screen Shot 2013-02-24 at 20.59.13
New-VHD -Path c:\temp\MobileData.vhdx -Dynamic -SizeBytes 10GB | Select-Object Path | Mount-VHD
Get-Disk | where PartitionStyle -eq "RAW" | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -UseMaximumSize -AssignDriveLetter -MbrType IFS | Format-Volume -Confirm:$false | Select-Object DriveLetter | ft -AutoSize
Copy-Item C:\ToVM -Destination E:\ -Recurse
Dismount-VHD C:\temp\MobileData.vhdx
Add-VMHardDiskDrive -VMName VMTest -Path C:\temp\MobileData.vhdx -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0

As you might know, why I use the SCSI controller is to be able to hot-add the virtual hard disk to the VM while it is running and not having to shut it down 🙂

The first time in the VM I have to do some massage on the disk before it appears but the next time the VM´s OS recoginize it and it can be used directly.

Screen Shot 2013-02-24 at 22.42.42
Get-Disk | where OperationalStatus -eq "Offline" | Set-Disk -IsReadOnly $false
Get-Disk | where OperationalStatus -eq "Offline" | Set-Disk -IsOffline $false
New-Item -Path E:\ToVM\ToHost -Type directory

And as you can see in the screendump above of the virtual machines folder with the files and also you can see that I can add data inside the VM to my virtual disk. If I would just use the Set-Disk -IsOffline $false I would get a volume that was write protected and here I wanted to add files and folders from the virtual machine also.

And when I am done moving files I can easily disconnect the disk from the VM from the host by using the following PowerShell cmdlet

Screen Shot 2013-02-24 at 22.06.39
Remove-VMHardDiskDrive -VMName VMTest -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0

This move folder and files way also works on the Windows 2012 Hyper-V!

Looking at the features in the Virtual PC compared to the client Hyper-V there are at lest two features I miss in the later,

  • Easily copying files between virtual machine and host
  • An network that can share the hosts without any extra manual configuration with the bridging creating a NAT solution out of the box.

Well you can´t get everything you wish for and some things you can create workarounds for 🙂

SC Orchestrator 2012 Sp1 and VMware vSphere 5.1

I have been exploring the System Center Orchestrator Integration Pack for vSphere and this is some good stuff! I have several customers that have bought Windows Datacenter Licenses with the System Center bundle and that is quite beneficial from a economical perspective! This means that they can use the System Center all parts with all VM´s and hosts. Several customers also use VMware vSphere as their virtualization platform and they can use System Center Orchestrator to build automation without any extra license cost.

In the System Center family there is only Virtual Machine Manager and Orchestrator that has connections to VMware vSphere without third party software (In Operations Manager you can use SNMP to get alarms from vCenter though).

So what can we do with Orchestrator IP for vSphere? This is the activities that is in the pack with version number 7.1.3010:

Screen Shot 2013-02-17 at 18.47.24

And what do we need to configure, well of course we need connection settings to a vCenter server and that is found under the “Options” and then you add your vCenter or if you have several and want to use them you will have to add one configuration for each.

Screen Shot 2013-02-17 at 19.12.05

And here is an simple example of a runbook that changes all VM´s memory to 384 MB, in the runbook I check if the VM is on or off and do an graceful power off activity depending on that status. For each activity in the runbook we have to add what configured vCenter we want to use or the runbook will fail!

Screen Shot 2013-02-17 at 19.19.42

The possibilites are almost endles as you can combine these activitiy with the others and interact with for example SCCM and deploy VM´s and OS. If this list of activities in the IP is not enough it can be extended by either creating your own IP or calling PowerCLI scripts from your runbook. Together with System Center Service Manager we can build nice self service portals that also does stuff on the VMware VM´s based on what the user order.

MAP 8.0 on Windows 8 and inventory VMware vSphere

This weekend I have been trying out Microsoft Assessment and Planning toolkit that late last year came in version 8.0. Last week I was attending a partner training in the DCCM PA on VMMT and one of the components in that is the MAP. The VMMT uses both SC Orchestrator and Veeam Backup and Replicaton to help in automating migration of VMware VM´s to Hyper-V.

I have been working a lot in NetIQ Platespin Recon and had some pointers to the MAP team last year at the MMS in Las Vegas, but not all ideas has yet find their way into this product and yes it is free to download so maybe the resources to this team are limited. I will show you two of the most annoying things later in this post.

I tried to install it on a Windows 8 and got the following error,

Screen Shot 2013-02-16 at 21.16.03

So with powershell I easily add the .Net 3.5 (It is not in there by default)

Screen Shot 2013-02-14 at 15.56.54
Screen Shot 2013-02-14 at 16.08.36

As you can see the output says it does not need a restart but when you try to install there will be an requirement error that says you must restart. and after that everything is ok and I successfully installed MAP.

As for when you want to inventory your VMware environment you do not need to enter every host, Point out the vCenter and an account to that and you are fine, MAP will then analyse and inventory that for hosts and VM´s. If you, as many customers I have been at, not changed your SSL certificate after installation of the vCenter it is important that you uncheck the following SSL verify check or you will not get any inventory data and it helps to also add an account that can talk wmi to the VM´s so you get more information about them.

Screen Shot 2013-02-16 at 21.42.10

So what is the annoying things with this great product. first of all it is not an service so when you want to capture performance data you have to have the application up and running the whole time it is collecting (and no that is not good design). In an migration and consolidation project you want to get data for at least a week and probably a month or more and then have to rely that the application is not closed during this time is not so good (fix that in MAP 9 please). The following screendump shows what dialog I get when I try to close the application

Screen Shot 2013-02-14 at 16.45.45

The next thing is that you might want to get some reports during the performance capture but that is not possible because the task processor is busy (well I heard about single thread applications but did not think they lived in 2013).

Screen Shot 2013-02-14 at 16.42.22

One thing they have fixed is when you are going to collect the performance data you no longer need to add the computers from a csv file as in earlier versions (did not try the 7.0 so do not know if it was fixed already then) but now actually get a list you can choose from!

Screen Shot 2013-02-16 at 23.53.39

Besides these small feature requests or what we should call them I think MAP is a great free tool to help you in getting good answers in your environment. It is not only for virtualization but also helps with answering if you can upgrade your servers to 2012 and also If your clients can run windows 8 and so much more.

Read more and find the link to download it for free here and try out for yourselves.

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!

Download all SC 2012 SP1 Evaluation VHD files with PowerShell

I was going to download the evaluation VHD´s for System Center 2012 SP1 and doing that the manual way by clicking on each of the links on the download pages and that for all SC 2012 products could seriously give you mental illness, If I counted the files correct it is 99 total + documents.

Screen Shot 2013-02-04 at 20.11.43

I found this guest post on the ScriptingGuys page where Marco did a PowerShell line how to not only find the files but also add them to BITS for download.  This script only works on PowerShell v3.0 because it is using the new Invoke-WebRequest cmdlet, and as you can see on the screendump how easily you can get all download links.

Screen Shot 2013-02-04 at 21.12.20

I have set the new url´s for SC 2012 SP1 RTM eval vhd´s  and added the .docx files and also do a check that in the volume you will store them have enough space, I made the assumption that it is approximately 70 GB total (99 files * ~700 MB each)

Here You can copy this and run on your environment, It will take some hours but at least it saves you the time in clicking 😛

# Download all SC 2012 SP1 VHD Eval
#
# Niklas Akerlund / Lumagate 2013-02-04
#

# Downloadfolder
$Dest = "D:\VHDEVAL"
$SizeOfSCSP1 = 70GB

# Get Space on volume
$SpaceRemaining = (Get-Volume $Dest.Split(":")[0]).SizeRemaining

if($SpaceRemaining -gt $SizeOfSCSP1){
# SCVMM
((Invoke-WebRequest -Uri "http://www.microsoft.com/en-us/download/details.aspx?id=36435").links | ? href -match "rar$|exe$|docx$").href | %{Start-BitsTransfer -Source $_ -Destination $Dest}
# SCOM
((Invoke-WebRequest -Uri "http://www.microsoft.com/en-us/download/details.aspx?id=36424").links | ? href -match "rar$|exe$|docx$").href | %{Start-BitsTransfer -Source $_ -Destination $Dest}
# SCORCH
((Invoke-WebRequest -Uri "http://www.microsoft.com/en-us/download/details.aspx?id=36426").links | ? href -match "rar$|exe$|docx$").href | %{Start-BitsTransfer -Source $_ -Destination $Dest}
# SCAC
((Invoke-WebRequest -Uri "http://www.microsoft.com/en-us/download/details.aspx?id=34781").links | ? href -match "rar$|exe$|docx$").href | %{Start-BitsTransfer -Source $_ -Destination $Dest}
# SCDPM
((Invoke-WebRequest -Uri "http://www.microsoft.com/en-us/download/details.aspx?id=36423").links | ? href -match "rar$|exe$|docx$").href | %{Start-BitsTransfer -Source $_ -Destination $Dest}
# SCCM
((Invoke-WebRequest -Uri "http://www.microsoft.com/en-us/download/details.aspx?id=36428").links | ? href -match "rar$|exe$|docx$").href | %{Start-BitsTransfer -Source $_ -Destination $Dest}
# SCSM
((Invoke-WebRequest -Uri "http://www.microsoft.com/en-us/download/details.aspx?id=36427").links | ? href -match "rar$|exe$|docx$").href | %{Start-BitsTransfer -Source $_ -Destination $Dest}
}else{
[int]$Sum = ($SizeOfSCSP1 - $SpaceRemaining)/1GB
Write-Host "Free up at least $Sum GB and try again!"
}

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 🙂

New version of the free vKernel Server Explorer

There is a new version of the free Dell vKernel Server Explorer and now the version number is 6.3

What has been added to this valuable tool:

  • Storage Explorer
  • Change Explorer

So with the storage explorer view I can get valuable information about the capacity and also the configuration of the datastores, such as what path selection, number of VM´s and IO etc

With the Change Explorer I get an overview of what has changed in my environment, this is data from the latest 7 days and if I want more I can always activate the vOPS server trial and then buy an license.

The Server Explorer can be installed/imported into VMware vSphere or Microsoft Hyper-V and also Redhat Enterprise Virtualization, and you can connect it to several vCenter servers and also Hyper-V and RHEV at the same time 🙂

I have tested to install it on Microsoft Hyper-V, I tried to use the guide and import the VM on a Windows 2008 R2 Hyper-V, this worked excellent. On windows 2008 r2 it is important that the config.xml file is present in the folder of the VM you try to import or it will fail, this is not a problem on windows 2012 hyper-v where you can import VM´s without exporting them first.

I changed the settings for the imported VM to

  • 4096 MB (I have also been able to start it with 2048 MB)
  • removed the legacy Network Adapter and replaced it with a Network Adapter (the synthetic)

Updated: The synthetic Network Adapter cannot be used when deploying on windows 2012 Hyper-V because the IC for linux on the vKernel Server Explorer appliance is version 3.1 and the OS is OpenSuse 11.4, and the IC 3.4 which is needed for 2012 cannot be installed on that OS. You can find out the version on your Linux VM by typing modinfo hv_vmbus or modinfo hv_netvsc for the network adapter. The recommendation from Microsoft is that you should use the Network Adapter when possible.

Screen Shot 2013-01-16 at 12.43.08

Then I started it and although the VM/VHD´s says 6.0 the VM after start says 6.3 So I know it is the latest and it starts successfully.

Screen Shot 2013-01-14 at 14.21.06

Next step is to configure the vKernel Hyper-V Collector, as you can see this is kind of mandatory before adding the System Center in the vOPS Server Explorer.

Screen Shot 2013-01-14 at 14.46.20

There are two different folders on the download and if you have System Center 2012 you should install the Hyper-V Collector 2012. If I had chosen the internal vOPS database I will use the SQL Server type PostgreSQL, the ip adress of the vOPS Server Explorer and the username and password postgres / postgres

Screen Shot 2013-01-14 at 16.05.27

Next step is to configure the connections tab where we add a connection to the SCOM server and when that is done we can after a while check the data in the web, the address is http://ip_of_the_vOPS , the name of my SCOM server is VMM12 so it is not the VMM server I connect to, although this server do have vmm and scom on the same OS.

Screen Shot 2013-01-14 at 21.57.44

Free tools are always nice and with these new change and storage explorers you get more insight into your environment and this for free!!

Good luck in your deployment of this updated tool!

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?!