This is about as informed as I can get. I'm gonna give you my personal story, and then the answer straight out of my microbiology book:)
I don't remember the exact timing during my pregnancy, but my doctor tested me for Group B streptococci and I tested positive. He sent me home with an antibiotic prescription that lasted for five days. It felt pretty strong to me because I had diarrhea during those 5 days. I believe they rechecked me just before delivery to assure that I was negative, and I was. Delivery was normal and induced.
Now here's my micro book explanation: Most microorganisms a baby will encounter in the birth canal are harmless. Some of them will become intimately associated with it. They will live in and on the baby becoming part of it's normal microbiota and will accompany it throughout life. Normal microbiota protect babies by creating an environment that is unfavorable for the growth of pathogens.
This is a case study, and the baby is referred to as Baby girl A: Baby girl A was at risk of encountering Group B streptococci because this pathogen had been present in her mother's vagina. Although Group B streptococci can cause a variety of serious diseases, Baby Girl A's mother was unaware of being colonized by this pathogen because she had no symptoms. Between 5 and 35 percent of pregnant women are similarly colonized by Group B streptococci and like Baby Girl A's mother do not show symptoms. But about 1 percent of infants born to such colonized women become infected and 5 to 8 percent of them die. The disease newborns suffer when infected with Group B streptococci at birth can strike quickly ro be delayed. Either eventuality is dangerous. Early onset disease, which begins within the first 6 days after birth, usually develops into meningitis. Late onset disease typically begins at 3 to 4 weeks of age. It usually results in septicemia.
Doctors swab the vagina and rectum to test for Group B strep.
Baby Girl A's mothe was given intravenously large doses of penicillin G. (penicillin G kills only certain bacteria, including Group B streptococci) Because of this preventative treatment, Baby Girl A passed through a birth canal that was loaded with a variety of microorganisms, but not Group B streptococci. She began to acquire her normal microbiota.
Well, I think that's about as in depth as you can get.