In the name of Allah, Most Gracious, Most Merciful.
Jabir (May Allah be pleased with him) reported: Messenger of Allah (May Allah exalt his mention and protect him from imperfection) used to teach us the Istikharah (seeking guidance from Allah) in all matters as he would teach us a Surah of the Qur’an. He used to say: “When one of you contemplates entering upon an enterprise, let him perform two Rak’ah of optional prayer other than Fard prayers and then supplicate: O Allah, I consult You through Your Knowledge, and I seek strength through Your Power, and ask of Your Great Bounty; for You are Capable whereas I am not and, You know and I do not, and You are the Knower of hidden things. O Allah, if You know that this matter (and name it) is good for me in respect of my Deen, my livelihood and the consequences of my affairs, (or he said), the sooner or the later of my affairs then ordain it for me, make it easy for me, and bless it for me. But if You know this matter (and name it) to be bad for my Deen, my livelihood or the consequences of my affairs, (or he said) the sooner or the later of my affairs then turn it away from me, and turn me away from it, and grant me power to do good whatever it may be, and cause me to be contented with it. And let the supplicant specify the object.” (Al-Bukhari and Muslim)
Riyaadiss-Saliheen (The Meadows of the Righteous)
By Imam An Nawawi
Chapter 97, Page 231, No 718