Some military recruiters are being denied access to high schools in the United States, a policy that is illegal and deprives students of learning the benefits of a military career, Defense Secretary Ash Carter said Tuesday.

Speaking to students at the City University of New York, Carter didn't mention any schools by same, but said the Pentagon plans to conduct a survey to identify which schools are restricting access in violation of federal law.

"The law requires schools to give our recruiters a basic level of access, and while it seems many schools are complying with that, recognizing that DoD might offer their students an exciting and impactful career, some others are putting up roadblocks," Carter said. "This is wrong."

Carter says the intention is not to penalize schools, but to "educate the educators" to help them realize that making it harder for military recruiters to do their jobs does a disservice to students looking for meaningful careers.

"Our goal here is to better educate schools about our mission, and help them realize they should want to let us in, because it would be a missed opportunity for their students if they didn't," Carter said.

Carter's speech extolled the virtues of working for the U.S. military, either in uniform or as a civilian, and touted the numerous reforms that have been implemented under his watch to make military service more family friendly and to increase its appeal to a younger generation.

He cited the lifting of the ban on transgender troops, the opening of combat jobs to women, increased child care, maternity and paternity benefits and policies designed to help married troops juggle the demands of military life.

"We're not only making military service more attractive," Carter said, "but also a place where you can maximize your talent and skills while doing one of the noblest things a person can do — helping defend our country and make a better world."

Carter also noted a district geographical divide in terms of volunteers for military service and at what level, and that pool of potential recruits seems to be shrinking.

Citing recent surveys, Carter said Americans from rural areas are twice as likely to join the military than young Americans from urban areas, and 40 percent of those who join the military come from just six states.

And he said most officers come from northern states, while the vast majority of enlisted troops come from the south.