The yield from the drugs discovered at premises, in Telford, was worth an estimated £14,000.
Kreshnik Lashi, 29, Dritan Paldeda, and Edison Poti, both 23, all admitted one count of production of a controlled drug Class B on April 7.
The Albanian nationals pleaded guilty on the basis that they were at the premises for a single night after being promised a payment of £300 each to prune the plants.
They told West Mercia Police they were living in London and had been driven to the area after being offered the money in return for cutting them.
Miss Olivia Appleby, prosecuting, said: "On April 6 this year the police received a call reporting a strong smell of cannabis and voices heard coming from an empty property. Police officers attended and after some time the door was answered.
"Immediately after stepping inside it became clear to officers that the property was being used for cannabis production. This was shown in photographs which were taken there.
"At least four rooms were used. A total of 166 plants were found in varying stages of maturity. All three defendants were arrested. All three gave similar accounts of their offending when interviewed.
"All three entered the country illegally."
She said Paldeda, of London, arrived in the country three years ago while Poti and Lashi, of no fixed abode, travelled to the country by lorry over a year ago.
"In London they frequented a restaurant run by other Albanians where they were offered to be picked up in a Mercedes and taken to the Telford address. It was their duty to cut the plants. It was made clear they would be paid £300 for doing so.
"All three had no previous convictions."
Judge Anthony Lowe told the hearing it was difficult to for the court to accept that the three men did not know of each other prior to them arriving in Telford.
Miss Appleby said inquiries made to check if they were connected had been fruitless.
Miss Debra White mitigating for Paldeda, who had initially denied the charge before changing his plea, said: "All the defendants have pleaded guilty on a basis that the crown does not challenge. He falls into a lesser role."
For production of cannabis Lashi and Poti were sentenced to eight months jail, and Paldeda to nine months to serve half.
However, the judge said the terms were equivalent to time already served as they have been in custody since their arrest. He said it was a matter for the Home Office to decide if they will be deported.
He ordered the forfeiture of cash totalling £500 seized from the defendants and the forfeiture and destruction of the drugs and paraphernalia.
The men were remanded in custody.