Q. What about Kiddush Levana (in prison)? Last night was the first time I saw the moon in 21 months. I made the Kiddush Levana through the window. Was that proper? Do I have to be outside to say the prayers? I could not be outside as I am always in doors.
A. Remoh (O.H. 426: 4) rules that Kidush Levanah should not be recited while under a roof. Mishnah Berurah (ibid. 21, from L'vush and Bach) explains that it is due to Kidush Levanah being tantamount to welcoming the presence of the Shechina and it is customary to go out to the streets to greet and receive kings. Others (Maharil) mention the tumah of an ohel or impurity propagated by a tent or roof, as the reason.
However Mishna Berurah also permits staying inside and reciting via an open door or window, when so needed, either because of illness, the street being unclean or the presence of hostile Gentiles. Orchos Rabeinu (p. 142) mentions that the Steipler Gaon Zt"l would recite inside when it was too cold and he felt weak.
If possible, when reciting inside, it is better to open the window. (Shaarei Teshuva ibid.)
Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit"a