I took a polygraph twice for an NSA internship (TS/CSI Clearance). It's an interesting process. In the first phase, you go over your security forms (SF-86 and related) in detail with your polygraph examiner. They ask a lot of detailed questions, sometimes including things you aren't legally required to disclose (drug use and foreign travel outside the listed time limits). In the second phase, they hook you up to the…
I used this to my advantage on more than one occasion, when the gaming group I was with was a bit too casual with their use of certain recreational pharmaceuticals. I told them straight out that my job required a lifestyle poly and random urinalysis, and that if they decided to do that to me the next morning, then I would be totally giving up my friends to the examiners. That usually convinced them to be more careful.
Strangely, the government never actually gave me a polygraph or urinalysis test, ever.