The first thing to do is to see if it is a power supply problem. You don't say whether it is a laptop or desktop? If it is a laptop does it happen when you do not have the power lead attached? If it is a desktop have you tried another power lead just in case it is faulty?
What is ransomware and how do I protect my PC from Petya?