If a person said the possuk “posei’ach ess yadechoh” in ashrei without kavana, he should repeat it. If he has gone further but did not yet get to the first hallellukah, he should go back to posei’ach and say from there and on. If he began the first hallellukah, he should finish it, and then say from possei’ach till the end of ashrei, and then continue from where he left off (and so on and so forth for the rest of pesukei d’zimrah). If he started yishtabach, he should repeat those pesukim (from posei’ach to the end of ashrei) after shacharis.
It is forbidden – mai’ikar hadin – for a man to be in a Shul if he does not have a head-covering.