Xbox turns on and off intermittently

I bought an xbox one, it came with a HD issues, so I have replaced and install the OS.
I have noticed an issue, when i’m using the xbox connected on a monitor pc, works fine and can play the games without any issue. But if i connect the xbox on my TV, the xbox starts to turn on and off constantly without touching it. I tested using different hdmi cables and connect into different hdmi port but still getting the same thing. Sometimes it connects on my tv, but just for a few seconds or minutes. Or sometimes my TV says hdmi is connected and then it shows lost signal. As anyone got this before?
Thank you