Performing exercise and getting into a sweat when you have a cold does work at least temporary to sweat out the cold.
But just exercising and sweating to sweat out the cold won't actually get rid of the cold virus that is causing the cold in the first place.
The exercise to sweat out a cold can work temporarily to provide temporary relief but the cold virus will still be there and you'll be feeling sick again soon.
The only real thing that works for getting rid of a cold is to rest, drink plenty of fluids, get vitamin C and within a week or 10 days the cold should be gone.
Taking some over the counter cold medicine can help with the symptoms but it won't fully get rid of the cold.