The fan has power when the switch is on while the fan speed and the light if the fan has one are controlled by pull chains on the fan itself or by a remote control device. Two wireswitches one switch turns power onoff to the fan the other to the lights.

Standard Single Pole Light Switch Wiring Hometips
Wiring a ceiling fan with light with one switch. An existing wall dimmer switch must be replaced with a single onoff wall switch before installing a hunter fan to ensure consistent power flow from the switch to the fan. The ceiling fan will have a black wire and another non white wire. There are several ways to control ceiling fans and light kits. Connect white wires together. Now for the trick. Thats usually the hot wire for the light.
Twist those two wires together then connect them to the black or red wire that came out of your electrical box. Pull chains to adjust fan speed and lights. For this youll need three twist on wire connectors. Connect the greencopper wires together. The wiring trick that lets you wire a ceiling fan with light to one switch. Remote control available on new or existing fans to adjust fan speed and lights.
Use whichever wire in the box the old light fixture was connected to. With single switch wiring power to the fan is controlled by a standard single pole wall switch like a regular light switch. One wireswitch to turn power onoff to the fan and lights at the same time. Wiring ceiling fan and light with one switch this method allows you to turn on the fan and the light from one single wall switch cutting out the necessity to use the pull chain every time you want to adjust the fan. That second wire is usually blue or red. A single wall switch controls the power to the fan and light together whereas a dual wall switch has two separate switches one for the fan and the other for the light.
The wiring diagram above is for typical installation wiring light is switched the fan is powered by a pull chain once you have found and identified all of the wires on your fan and in your electrical box you can get to work on connecting them.