I have owned 2 Z4 coupes (build dates Jan and July 2007), and have had the same problem on both.
The first Z4 had the squeak from brand new ... if you open the windows slightly whilst driving, the squeak goes away.
I contacted BMW Sydney about the issue ... they advised me to get some silicon lubricant spray, and dab a little onto the black rubber seals on the door frame ... i.e onto the rubber seals that the window closes against when you close the door. When you apply it, make sure to leave the window half open, so that when you close the car door, the window does not touch the rubber seal, so it can dry for a few hours before you raise the windows ... otherwise the silicon lubricant gets onto the windows, and it leaves awful streak marks which are difficult to remove.
Oddly enough, the Z4 Owner's Handbook specifically advises one NOT to use silicon spray ... but I tried it, and it worked ... for a while ... and then the noise comes back and one has to put some more on.
The second Z4 coupe also has the noise ... when you go over bumps or brake ... and the noise also seems to stop when the window is left a couple of cm open .... I've tried the silicon spray again ... no luck so far on this car. (Only recently got the car, so haven't looked into this properly). If it doesn't work, I'll have to ask BMW to change the door seals.