Hello,
Windows Server 2012 R2 does not include a consumer-style Reset this PC feature, so a “factory reset” is effectively a clean reinstall from installation media (or an OEM recovery image if your hardware vendor provided one).
Before you wipe the box, export your drivers so you can restore them later: open an elevated Command Prompt and run pnputil /export-driver * C:\DriverBackup and copy that folder off the server.
If you want a full roll-back plan, install the Windows Server Backup feature and take a Bare Metal Recovery backup to external storage (wbadmin start backup -backupTarget:E: -allCritical -quiet) so you can restore the entire machine if needed.
To reinstall, download the official 2012 R2 ISO from your volume licensing portal, create a bootable USB, boot from it, choose Custom: Install, delete the existing OS partitions, and proceed with setup.
After setup, install the chipset/storage/network drivers from your server vendor first, then run Windows Update to pick up inbox drivers and security fixes.
To restore the driver set you exported, copy back the folder and run pnputil /add-driver C:\DriverBackup\*.inf /subdirs /install.
If your vendor shipped an OEM recovery partition or image, you may use their recovery tool to return to the factory state (this is hardware-specific; check the server model’s support page).
For faster future rebuilds, consider capturing a reference image: install the OS, vendor drivers, updates, and agents, then run sysprep /generalize /oobe /shutdown and capture with DISM or your imaging tool.
Because Server 2012 R2 is out of support, I strongly recommend planning an upgrade path (2019/2022) once the machine is rebuilt, for security and servicing. And if this answer helps, feel free to hit “Accept Answer” so others can benefit too 😊