How to install OS X into Hyper V (For Windows)

This post shows how to spawn OSX in Windows Hyper-V using OSX-Hyper-V repo - A Hackintosh project implementing the MacHyperVSupport package for Windows Hyper-V, built on top of the OpenCore bootloader and OCE-Build build manager.
Open PowerShell from admin:
winget install --id Git.Git -e --source winget
winget install --id Python.Python.3.8 --source winget
git clone https://github.com/Qonfused/OSX-Hyper-V
cd OSX-Hyper-V
If you have intel with generation Intel Tiger Lake and newer (11th Gen and newer)
Open
notepad.exe .\src\config.yml
And add there:
Kernel:
Emulate:
Cpuid1Data: Data | <55 06 0A 00 00 00 00 00 00 00 00 00 00 00 00 00>
Cpuid1Mask: Data | <FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00>
Build:
.\scripts\build.ps1
Now create VM:
.\dist\Scripts\create-virtual-machine.ps1 -name "MyOX"
Open HyperV, start VM and connect to it
Go to Disk utility and erase drive (first one, named Microsoft ...)
Go to Reinstall OS X
Logging in into AppStore
To install software like XCode you need to login into AppStore. You might get "An unknown Error has occurred". This happens if OSX detects VM.
You can check fact that OSX detected VM by executing
sysctl kern | grep 'kern.hv_vmm_present'
What helped me on latest up to this day Sequoia 15.4.1 to fix it is mounting C:\Users\xxxx\Documents\Hyper-V\MyX\EFI.vhdx (go to folder, double click to mount), then open EFI/OC/config.plist
There find
<dict>
...
<key>Kernel</key>
<dict>
...
<key>Patch</key>
<array/>
And replace it with
<dict>
...
<key>Kernel</key>
<dict>
...
<key>Patch</key> <array> <dict>
<key>Arch</key>
<string>x86_64</string>
<key>Base</key>
<string></string>
<key>Comment</key>
<string>Sonoma VM BT Enabler - PART 1 of 2 - Patch kern.hv_vmm_present=0</string>
<key>Count</key>
<integer>1</integer>
<key>Enabled</key>
<true/>
<key>Find</key>
<data>aGliZXJuYXRlaGlkcmVhZHkAaGliZXJuYXRlY291bnQA</data>
<key>Identifier</key>
<string>kernel</string>
<key>Limit</key>
<integer>0</integer>
<key>Mask</key>
<data></data>
<key>MaxKernel</key>
<string></string>
<key>MinKernel</key>
<string>20.4.0</string>
<key>Replace</key>
<data>aGliZXJuYXRlaGlkcmVhZHkAaHZfdm1tX3ByZXNlbnQA</data>
<key>ReplaceMask</key>
<data></data>
<key>Skip</key>
<integer>0</integer>
</dict>
<dict>
<key>Arch</key>
<string>x86_64</string>
<key>Base</key>
<string></string>
<key>Comment</key>
<string>Sonoma VM BT Enabler - PART 2 of 2 - Patch kern.hv_vmm_present=0</string>
<key>Count</key>
<integer>1</integer>
<key>Enabled</key>
<true/>
<key>Find</key>
<data>Ym9vdCBzZXNzaW9uIFVVSUQAaHZfdm1tX3ByZXNlbnQA</data>
<key>Identifier</key>
<string>kernel</string>
<key>Limit</key>
<integer>0</integer>
<key>Mask</key>
<data></data>
<key>MaxKernel</key>
<string></string>
<key>MinKernel</key>
<string>22.0.0</string>
<key>Replace</key>
<data>Ym9vdCBzZXNzaW9uIFVVSUQAaGliZXJuYXRlY291bnQA</data>
<key>ReplaceMask</key>
<data></data>
<key>Skip</key>
<integer>0</integer>
</dict>
</array>
For newer versions check issues on GitHub repo page