A community has escaped being plunged into darkness as a young man has been arrested for trying to steal a transformer.