To get from airport CDG directly to Versailles, you’ll need to take the RER B train from either Airport Terminal 2 or Terminal 1 train station towards Paris and change trains once at the stop St. Michel/Notre Dame. Here are full detailed instructions on getting to Paris from Charles de Gaulle.
At metro/RER station Saint Michel / Notre Dame, you’ll switch from RER B (blue line) to RER C (yellow line), heading in the direction of Versailles-Rive Gauche. Follow the overhead and wall signs to get to the correct RER C yellow line platform. The signs should read RER C Versailles-Rive Gauche and perhaps other names like Saint-Quentin-en-Yvelines.
Once you arrive at the correct train platform, note the black overhead RER train stop panels with plenty of names and yellow squares that may or may not be lit beside them. Each yellow square beside a name means that the next train which arrives at this platform, will stop at those stations along the way to its final destination. Double check that one of these names should say Versailles-Rive Gauche and be lit with a yellow square beside the name. If the name is not lit, but you see it on the panel, the next train will not stop there. Wait until the next train passes and the sign changes to show a lit yellow square beside Versailles-Rive Gauche.
See this page for detailed instructions on getting from Paris to Versailles by train.