The effect of grain boundary on electrical transportation properties is a basic physical problem and also a subject of material science and technology. In situ electrical measurement of powdered materials under high pressure provides a chance to figure out the electrical properties of grain boundaries. In this letter, the authors report an in situ impedance spectroscopy method used in conjunction with a diamond anvil cell for electrical property research of grain boundaries under high pressure. Powdered CdS was pressed up to 23 GPa and an impedance arc corresponding to the grain boundary was detected. It was found that the electrical property of the grain boundary changed with pressure and could be determined by the resistance and the relaxation frequency. Pressure decreases the effective scattering section of the grain boundary to charge carriers, and finally leads to the decrease of resistance and activation energy of the grain boundary.