1) Convert the vmdk to a vhx.
There is a Microsoft tool that will convert the vmdk to a vhdx for you which can be downloaded here: https://www.microsoft.com/en-us/download/details.aspx?id=42497.
2) Create the batch file below and drag and drop the vmdk on to the convert.bat script.
Note: Pay attention to the location it lists when done because, even though the script specifies the same destination path as source path, it may put the vhdx in "c:\windows\system32\"
"convert.bat" should contain the following batch code (you might need to update the file path):
@echo off
REM --add the following to the top of your bat file--
set file=%1
FOR %%i IN ("%file%") DO (
set filedrive=%%~di
set filepath=%%~pi
set filename=%%~ni
)
set dst="%filedrive%%filepath%%filename%.vhdx"
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "cmd.exe", "/c %~s0 "%1" "%dst%"", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
echo "%1 => %2"
PowerShell.exe -Command "& Import-Module 'C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1' ; ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath '%1' -DestinationLiteralPath '%dst%' -VhdType DynamicHardDisk -VhdFormat Vhdx"
pause
3) Create a new Hyper-V machine (**generation 1 is required**).
***You must disable Secure Boot***
Allocate memory to the VM (minimum is 4096 for smaller networks. recommend 8GB)
Find the virtual harddisk that you converted
Create a Virtual Switch
Remove Network Card (they need to be legacy adapters)
Create 2 Legacy Adapters connected to new Virtual Switch
Turn on the VM and ensure you have an IP address
Reference this article to setup a static IP if required.
4) To capture traffic from a Hyper-V VM you also need to follow these steps: http://www.arubanetworks.com/techdocs/ClearPass/6.6/InstallingOnVM_6.6_TechNote/Content/InstallOnHyperV/SPANconfig_HyperV.htm
Comments