Chosen Solution

First of all it was not powering on with no LEDs lighting up on the logic board. I got a replacement power supply, fitted it and then I had the 1st LED on but it still did not power on. I took out the logic board and took out the battery and re-seated the CPU and put it back together and it turned on and booted as soon as I plugged in the power (without hitting the power button). I restarted it several times and then eventually turned it off and tried hitting the power button but it seems like the power button is broken. I could not turn it off by holding the power button in while it was turned on. Is there any way to short it on the board to see if it powers on and be certain the power button is definitely broken? I can’t seem to be able to find a replacement button anywhere online.

The power button is not an Apple replaceable part ;-{ Its part of the rear case assembly. You should be able to disconnect the cable and using a jumper short across the sockets solder connections to test the switch logic. Review Step 33 in this guide iMac Intel 21.5" EMC 2544 Logic Board Replacement