Ayesha reported that whenever the wind blew strongly, the Prophet ﷺ would say, "O Allah, I ask You for its good, the good of what is in it, and the good of what it was sent with, and I seek refuge in You from its evil, the evil of what is in it, and the evil of what it was sent with."She said, "And when the sky grew dark with clouds, his color would change, and he would go out and come in, pace forward and back. Then when the rain fell, his distress would leave him, and I could see the relief in his face."Ayesha said, "So I asked him about it."He replied, "Perhaps, Ayesha, it is as the people of Aad said, 'Then when they saw it as a cloud advancing toward their valleys, they said, This is a cloud bringing us rain'" [Ahqaf 46:24].
أنها قالت: كان النبي ﷺ إذا عصفت الريح قال: اللهم إني أسألك خيرها وخير ما فيها، وخير ما أرسلت به، وأعوذ بك من شرها، وشر ما فيها، وشر ما أرسلت به قالت: وإذا تخيلت السماء تغير لونه، وخرج ودخل، وأقبل وأدبر، فإذا مطرت سري عنه، فعرفت ذلك في وجهه قالت عائشة: فسألته فقال: لعله يا عائشة كما قال قوم عاد: {فلما رأوه عارضا مستقبل أوديتهم قالوا هذا عارض ممطرنا}.
Bukhari narrated it in the Book of the Beginning of Creation (3206), and Muslim in the Book of the Prayer for Rain (899:15), both through Ibn Jurayj, from Ata bin Abu Rabah, from Ayesha, as I have related it. The wording given is Muslim's. Bukhari has only the second half of it and does not have the part about the supplication.