# Bare Metal with Hyper-V

Using Hyper-V is a great way to start with testing your DeployR environment.  Grab the DeployR ISO file from the boot folder, copy it to your Hyper-V host, then boot a Hyper-V VM to that boot ISO

#### Recommendations / Requirements  for Hyper-V VM

* Gen2 VM
* 8GB memory, if resource constrained, 4GB minimum for basic client OS testing.
  * VERY IMPORTANT, **DISABLE DYNAMIC MEMORY**!  This has been the number one cause of the "Apply OS" step failing as Hyper-V pulls back memory and the device doesn't have enough to apply the image.
* 4 Virtual CPUs
* Default Storage sizes are fine, but feel free to tweak if you like.
* Ensure has network connectivity to reach the DeployR server
* Set the DVD to the DeployR Boot ISO

<figure><img src="/files/ByL8ajL3FvFqBF1oru0T" alt=""><figcaption></figcaption></figure>

PowerShell Code Snips.  This will generate a VM for you.

```powershell
$VMName = "VM-OSD-01"
$VMPath = "C:\HyperV"
$BootISO = "C:\HyperV\DeployR_x64_noprompt.iso"
[int]$ProcessorCount = 4
[int]$StartingMemory = 4 #GB
[int]$DriveSize = 100 #GB
$VMSwitchName = 'External'

#=====================================================

$VMFolder = Join-Path -Path $VMPath -ChildPath $VMName
$VHDxFile = Join-Path -Path $VMFolder -ChildPath "$VMName.vhdx"
$MemoryBytes = $StartingMemory * 1024 * 1024 * 1024
$DriveBytes = $DriveSize * 1024 * 1024 * 1024
$NewVM = New-VM -Name $VMName -Path $VMPath -MemoryStartupBytes $MemoryBytes -BootDevice CD -SwitchName $VMSwitchName -Generation 2
Set-VMMemory -VMName $VMName -DynamicMemoryEnabled $false -StartupBytes $MemoryBytes -ErrorAction Stop
$NewVHD = New-VHD -Path $VHDxFile -SizeBytes $DriveBytes -Dynamic -ErrorAction Stop
Add-VMHardDiskDrive -VMName $VMName -Path $VHDxFile -ErrorAction Stop
Set-VMSecurity -VMName $VMName -VirtualizationBasedSecurityOptOut:$false 
Set-VMKeyProtector -VMName $VMName -NewLocalKeyProtector
Enable-VMTPM -VMName $VMName
Set-VMProcessor -VMName $VMName -Count $ProcessorCount
Set-VMVideo -VMName $VMName -ComputerName $env:COMPUTERNAME -ResolutionType Single -HorizontalResolution 1600 -VerticalResolution 900
Set-VMDvdDrive -VMName $VMName -Path $BootISO
```

If you want to go advanced, here is a script with a few extra checks and paramters for doing some automation.\
<https://github.com/2pintsoftware/2Pint-DeployR/blob/main/Hyper-V/BuildVMsGeneric.ps1><br>

### Secure Boot, Hyper-V and iPXE

Disable Secure boot for iPXE... and here's why...\
the iPXE binary is signed by Microsoft's UEFI Certificate Authority (for 3rd Parties), which is different than the standard Windows Secure Boot Certificate.  Most devices will allow either of these options to boot a device, Hyper-V however does not, you have to pick one or the other, which doesn't work well for iPXE.

<figure><img src="/files/Br7roQbzOkGvrnKn5fdY" alt=""><figcaption></figcaption></figure>

This is where you have a catch 22, if you change the drop down to use template Microsoft UEFI Certificate Authority, then iPXE will boot with Secure Boot, however when you pull down and try to load your WinPE, that's not signed with the Microsoft UEFI Certificate Authority, and requires the Microsoft Windows template option, the boot process will then fail the Secure Boot auth.\
\
This is a Hyper-V limitation, which doesn't exist in VMWware or Physical devices, so if you're doing testing with Hyper-V and iPXE, you will need to disable the Secure Boot (Remove the checkbox from "Enable Secure  Boot".<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.2pintsoftware.com/deployr/bare-metal-with-hyper-v.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
