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.
On the properties window, select the Compatibility tab, check “Run this program in compatibility mode for:” and select "Windows 7".