A man who kicked a community defibrillator onto a train track while on a community service order has been sentenced.