SciVision and Michael Hirsch, Ph.D. provide these links and information to raise community awareness for qualified information security professionals, without liability for incorrectness or incompleteness of this information.
Blindly copying and pasting commands can lead to drastic personal and corporate loss of information and availability.
{: .alert-box.warning}

Per Microsoft, WannaCry attacks SMBv1 Servers.
The sections below disable SMBv1 protocol based on
Microsoft procedures.
That is, PCs that are simply sitting unattended and unused by humans can be infected by WannaCry
attacking SMBv1 on port 445.
The ability for unattended PCs SMBv1 to be
attacked on local networks
is particularly hazardous as proven for healthcare and industrial facilities being disabled.

Verify System Patches

This technique has the weakness that each operating system version has unique KB numbers, so you need to run this uniquely for each operating system version.
Consider scripting this to try several KB numbers and return code on success for further automation.
The KB numbers are are obtained from Microsoft
Security Bulliten

Here’s an example for Windows 7 64 bit from Command Prompt as Administrator:

If it’s installed, a message is printed starting with Package Identity :

Notes

As a general rule, I set Windows computers to have Network configuration as below.
This disables network file shares, network printing, etc., which is fine for me since I only use Windows computers when forced to for isolated instrumentation.
This alone won’t protect you from WannaCry, but is a general practice I take on.