Install macOS in VirtualBox

First you need an ISO file of the macOS installation DMG. Either download that file from the internet (please be advised to use safe sources) or you follow a tutorial to convert the DMG to an ISO. A tutorial is given here:

https://www.xda-developers.com/how-install-macos-virtualbox

Simply install macOS by adding a virtual machine an selecting the ISO and system as macOS. After the VM was added, change the config as follows:

  • Min 2-core CPU
  • Min 4 GB RAM
  • Min 40 GB HardDisk
  • Min 128 MB VboxVGA with 3D acceleration enabled

Please note that you may need to set the CPU count to 1 for correct installation, otherwise kernel panics can happen! Also set your USB controller to USB 3.0 in case the mac installer asks you for a mouse or keyboard.

Last steps, you need to execute special config commands in terminal:

$ VBoxManage modifyvm "VM_NAME" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff

$ VBoxManage setextradata "VM_NAME" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"

$ VBoxManage setextradata "VM_NAME" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"

$ VBoxManage setextradata "VM_NAME" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"

$ VBoxManage setextradata "VM_NAME" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"

$ VBoxManage setextradata "VM_NAME" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Join macOS to Active Directory

Simply execute following commands:

$ dsconfigad -domain <domain_name> -a <hostname> -u <domain_admin_user>
$ dsconfigad -groups "domain admins","enterprise admins","my custom admin group"
$ dsconfigad -mobile enable -mobileconfirm disable

The first command will join the computer to the domain. Please make sure you are using the hostname given by the hostname command, not the one defined in the sharing settings and the user which you are using for joining has the “domain admins” group by default.

The second command sets all the groups which are allowed to manage the computer

The third command is used to enable mobile logins (must be used in case the computer is not always connected to the domain, e.g. macbooks leaving the network).

More infos on apple’s page:

https://support.apple.com/en-gb/guide/directory-utility/diru11f4f748/6.3/mac/13.0