Captain Janeway dismisses the importance of a nebula that the U.S.S. Voyager is currently passing through. Her next order of business is from the ship's holographic doctor, who wishes his program to be altered so he can take command if needed. Janeway rejects this plan. To boost his morale, the Doctor implements a plan allowing himself to daydream.
However, in the nebula, a Hierarchy starship is hidden. One of the crew members sights Voyager and gets permission from the Hierarchy to use the Doctor as a method to spy on Voyager. However, the Doctor's daydreams become the "vision" that the crew member sees. The crew member reports this to the Hierarchy. However, the captain sees something else - Voyager's store of antimatter. Meanwhile, the Doctor is having trouble telling reality from his fantasies.
The enemy ship decides to use a "Stealth 3" plan to destroy Voyager and get the antimatter. However, the crew member warns the Doctor through his daydreams about the situation. The Doctor is then told that he should act as the captain because one of the daydreams the Hierarchy saw was the Doctor daydreaming about turning into the captain. The Doctor tells Janeway of this. Initially she believes the Doctor simply has lost touch with reality again. She is soon convinced and the Doctor's original command program is implemented for real. Janeway, however, works from a hiding spot to give the Doctor advice and orders.
Unfortunately, the Hierarchy vessel has obtained permission to proceed to a "Stealth 4" assault instead. Instead of a warning shot being fired before boarding the ship, a full phaser blast is used. The ship is rocked. The Doctor decides to use one of his fantasies, which the enemy believes is reality. He declares he will implement the photonic cannon, an entirely imaginary weapon. This bluff succeeds and the enemy retreats.
The episode ends with Janeway giving the Doctor the Starfleet Medal of Commendation and telling him that she will assign a team to research adding command functions to a hologram.