An Oak Bluffs man was sentenced to state prison last week after pleading guilty on child pornography charges.

Joshua L. Rogers, 31, pleaded guilty Friday on two counts of purchasing or possessing child pornography. The charge dates to February 2017. Mr. Rogers was arrested in May 2017 and indicted by a grand jury last fall.

The Hon. Gary A. Nickerson, an associate justice of the Dukes County superior court, sentenced Mr. Rogers to three to four years at MCI-Cedar Junction, a maximum security prison in Walpole, on the first count. He was also ordered to submit a DNA sample and to register as a sex offender.

On the second count Mr. Rogers was sentenced to two years of probation concurrent with the first sentence, and ordered to complete treatment and not to live with or be in contact with minor children.

The sentence was part of a joint agreement between the prosecution and defense. “This young man has never had a chance in life,” Robert Moriarty, Mr. Rogers’s attorney, told the court. “This is a chance to get help.”