The first part of my answer is a bit of a frame challenge, but it is vitally important: think carefully to make sure that denying them AI is appropriate to the circumstances. My current CS courses have different policies, ranging from, "do not use it to create any code under any circumstances" to "you can feel free to use any AI source you wish for the code you produce in this class" and everything in between.
The differences stem from the learning goals of the courses, and. It tends to be that more advanced courses, importantlywhere programming is no longer the focus of the curriculum, within metend to have more relaxed GPT policies.
Now on to the nitty-gritty:
Within my department, we begin each course with the GPT policy, and a discussion withabout why, given the learning goals of the course, the policy is the way it is,. We then follow with very detailed instructions about how, exactly, to comply with the policy, and how we expect this policy to ultimately benefit the students.
In my own courses, I also begin each assignment with a short description of the lab's learning goals, how GPTs can (or cannot) be used very specifically within the assignment, what sort of citations I expect and where, and, again, why I believe that this policy will help the students in the long run. I believe that these discussions give context that helps students make better decisions about their own behavior, and frame the lab experiences in a way that helps the students to also learn what the lab is trying to teach them.
The second part, helping them to avoid it, is fairly straightforward: first, we explain that, due to the ease of cheating with AI (not to mention other, more traditional sources), we have been forced to make labs worth comparatively less within grades. Second, we explain that the exams and labs are designed, to some degree, together; the labs are intended to help prepare students for the exams, and cheating on labs may well impact preparedness for the tests, during which students are watched.
Importantly, we are telling the truth about this. The exams really do include components from the labs. If we didn't, the students would shortly figure out that the labs really don't impact their grades much, and they would treat them as such. What we put on the test can be something as complex as questions about structures or techniques that they practiced on the lab, or as simple as creating a short method that they would have literally coded on it (such as a linked list insertion at the end of a list).
In my experience, working to get the students on your side by showing them how your AI policy is ultimately on theirs goes a long way, and setting up your course incentives properly can do much of the rest.
Does this prevent 100% of such cheating? No, of course not, but judging from how hard I see students working on the labs I give, I can tell you that it goes a long way. Students will focus their work where they feel like the work is rewarded, and this is as true in the age of AI as it has ever been.