programmicaly switch electric power
The obvious solution would be an off-the-shelf USB relay board.  Lots of people sell them.  Using a relay provides isolation between the computer and the thing being switched.