You have asked a complicated question, and the answer is no less complicated.[1] It is questionable if an elevator requires a mezuzah at all, and opinion differ on the matter. The standard elevator is comprised of two parts: the moving compartment and the outer shaft. There are reasons to exempt both. A moving compart may not be considered a room, simply because it moves. The shaft in of itself is exempt because nobody enters it. That which a technician enters the shaft periodically is not enough for it to require a mezuzah. Hence, many exempt an elevator entirely.[2] However, some maintain that nevertheless, since one enters the shaft while in a compartment, the shaft is obligated.[3] Thus, they place a mezuzah on the right side entering the shaft on the ground level, and on the entry of each floor, on the right side exiting the shaft, following the direction of entry. However, even those following this opinion do so without reciting a blessing, out of doubt.[4]
The above applies only in a building where all the occupants are Jewish. If even one occupant is not Jewish, the elevator does not require a mezuzah.[5] This is one of the reasons why a mezuzah on an elevator is almost unseen in the Diaspora.[6]
[1] This Q & A was compiled by Shmuel Kraines, based on Agur B’Ohalecha (36:45), and as heard from its author.
[2] R’ Wozner (Kobetz Beis HaLev, Tishrei 5753), R’ Nissim Karelitz (Moriah, Shevat 5771), B’tzel HaChachmah (II, §80-85), and R’ Moshe Feinstein (cited in Agur B’Ohalecha, ibid.).
[3] Chovas HaDar (5:11). See also Minchas Shlomo (II, 96:23). This is comparable to the entrance of a city which is exclusive for cars. It requires a mezuzah even though one enters it only while inside a car, which is in of itself exempt, as it is not a permanent dwelling. It should be stressed, that the mezuzah should not be place on the door of the moving compartment, but rather on the doorway of the shaft.
[4] Minchas Shlomo (ibid.).
[5] Rema (286:1) exempts a house which is owned partly by a non-Jew. Although there is an opposing opinion (see Agur B’Ohalecha 29:7-10), regarding an elevator, which is questionable in its own right, one need not be stringent.
[6] A further reason may be because of the risk of anti-Semitism, or in accordance with the lenient opinions.