In April 1862, Polk commanded the First Corps of Albert Sidney Johnston's Army of Mississippi at the Battle of Shiloh and continued in that role for much of the rest of the year under Beauregard, who had assumed command following the death of A. S. Johnston on the first day at Shiloh, and then under Gen. Braxton Bragg. At various times his command was considered a corps and at other times the "Right Wing" of the army. In the fall, during the invasion of Kentucky by Bragg and Maj. Gen. Edmund Kirby Smith, Polk was in temporary command of the Army of Mississippi while Bragg visited Frankfort to preside over the inauguration of a Confederate governor for the state. Polk disregarded an order from Bragg to attack the flank of the pursuing Union Army near Frankfort.