Microsoft Security Essentials, the predecessor of Windows Defender, is an official security program by Microsoft and can be installed on Windows Server 2012 R2 and earlier OS.
On Windows Server 2016 and later OS, please install Windows Defender via Server Manager.
Once MSE is installed on Windows Server 2012 R2 with special steps, we can make full scan of the system to detect virus and spy software.
1, Download installation file MSEInstall.exe from link:
2, Change Compatibility property for the downloaded file.
On the properties window, select the Compatibility tab, check “Run this program in compatibility mode for:” and select "Windows 7".
3, Install MSEInstall.exe with command parameter MSEInstall.exe /disableoslimit
4, Update application, make a full scan, and remove virus and spy software.