I would verify the PSU is bad before replacing it. I keep a
FrozenCPU Ultimate PSU Tester in my travel tool bag. It is not as good as a qualified technician testing the power supply unit (PSU) under a true load with a oscilloscope, but close. The advantage of this model is that it has an LCD readout of the voltage. With an actual voltage readout, you can better detect a "failing" PSU. Lesser models use LEDs to indicate the voltage is within some "range". These are less informative, considerably cheaper, but still useful for detecting PSUs that have already "failed".
Newegg has several testers to choose from. All these testers contain a "dummy load" to fool the PSU into thinking it is connected to a motherboard, and therefore allows the PSU to power on, if able, without being attached to a motherboard - great for testing fans too. Alternatively, you can swap out the PSU with a known good one that meets the computer's power requirements.
If you do decide on a new PSU, use the
eXtreme PSU Calculator Lite to determine your power supply unit (PSU) requirements. Plug in all the hardware you think you might have in 2 or 3 years (extra drives, bigger or 2nd video card, more RAM, etc.). Be sure to read and heed the notes at the bottom. I recommend you set Capacitor Aging to 30%, and if you participate in distributive computing projects (e.g. BOINC or Folding@Home), I recommend setting TDP to 100%. Research your video card and pay particular attention to the power supply requirements listed on your video card maker's website for your card. Then look for power supply brands listed under the "Good" column of
PC Mechanic's PSU Reference List. Ensure the supplied amperage on the +12V rails of your chosen PSU meets the requirements of your video card. Don't try to save a few dollars by getting a cheap supply. Digital electronics, including CPUs, RAM, and today's advanced graphics cards, need clean, stable power. A good, well chosen supply will provide years of service and upgrade wiggle room. I strongly recommend you pick a supply with an efficiency rating equal to, or greater than 80%.
Note your problem could also be caused by malware. Have you done a complete malware scan? That is usually the first thing I do when troubleshooting a PC so I know I have a clean platform to work from. Here's a link to my canned text on
Cleaning Out Malware. Use it if you don't already have a
complete security suite and disk cleaning utilities to rid your system of malware and clutter. You can also use it as a guide to build your own security suite, and to help you develop a "
Practicing Safe Computing" self-discipline.
Other causes could be bad or failing RAM, bad hardware drivers or failing hardware. Start by disconnecting all USB devices, such as thumb drives and external drives.
And connections can work loose over time too. I would power down, UNPLUG the computer, then open the side panel and make sure all connections are secure. Make sure the insides are not full of heat trapping dust and dirt too.