A cell search, also known as shakedown, is an event in which the guards will choose 2 inmates, then they will check their cells and Desk for any contraband. If contraband is found, it will be confiscated and you will be sent to Solitary, or in The Escapists 2, the Security Level will rise if the searching guard reaches the Control Room.
They also cover up holes in the wall and floor, such as if you were planning to escape or get to a Prisoner Stash. If you have anything that's left uncovered like a vent or a hole or if you have contraband in your desk, they will take it away, cover up the holes, and put you in solitary. In The Escapists 2, a guard who finds damage will also go to the control room and increase the security level.
However, there are ways to avoid having your contraband confiscated if you are chosen for shakedowns. You can store up to 3 items in your toilet without flushing them, and they will not find them, but after exiting game they will disappear. Remember to take them out before night or else you will lose all items that are in the toilet. (note: this method has not been tested on console/mobile editions and may not work for those platforms. Also worth noting is that this does not work in The Escapists 2, as any items left in the toilet will be returned to your inventory upon closing the menu.) In The Escapists 2, you can knock out the guard before they search your desk. You will gain the heat, but retain your contraband. You can also simply place items in the Hidden Compartment of your desk.
You will know which guards are going to search cells, as they walk at normal speed toward the targeted cell while displaying three red lines above their head (the 'yelling' or 'angry' symbol.)
It is announced by the 3 main Guards during roll calls. They always announce two Inmates to be searched at each roll call. In the Escapists 1, they announce them at the beginning of the roll call, while they announce it at the end in The Escapists 2. After Rollcall in TE2 the inmates getting a shakedown will appear on the information board (top left). Also a desk search icon will appear on the minimap if your desk is getting searched. This gives you time to prepare your desk.