This is described in Brhadaranyaka Upanishad I. iv. 1. and Sankara's commentary on this verse. The verse reads (Swami Madhavananda translator):
In the beginning, this (universe) was but the self (Viraj) of a human form. He reflected and found nothing but himself. He first uttered, 'I am he.' Therefore he was called Aham (I). Hence, to this day, when a person is addressed, he first says, 'It is I,' and then says the other name that he may have. Because he was first and before this whole (band of aspirants) burnt all evils, therefore he is called Purusa. He who knows thus indeeds burns one who wants to be (Viraj) before him.
A brief summary of this verse and Sankara's commentary is done by Swami Nikhikananda (The Upanishads, V1, p 74):
Too give a brief outline of this interpretation of the creation: In the beginning--that is to say, before the evolution of names and forms, time and space--Atman, or Brahman, alone exists. Then it becomes conditoned by maya, Its own inscrutable power. At that time Brahman is called Saguna Brahman--Mahesvara, or the Great Lord. The idea of creation arises in his mind. Sa aikshata-- "He thought." Then Brahman, on account of maya, forgets, as it were, Its infinite nature and regards Itself as an individual entity. It says: "I am one; I shall be many."
Three "moments" are to be distinguished in creation: First, the Supreme Brahman accepts the limitation of maya and becomes Mahesvara. Second, the desire for creation arises in his mind. Third, He feels his loneliness and decides to multiply Himself. Then, with the help of maya, He creates akasa, air [or space] and the other elements.
Mahesvara, who is the Ruler of all the Brahmandas, is thus the First Person in the creation. Hiranyagarbha, or Brahma, who as a result of spiritual disciplines practiced in a previous cycle, becomes the Ruler of a Brahmanda, is the Second Person. Though possessed of an individuality, He identifies Himself with the whole universe; He is described in the Vedas as endowed with innumerable heads, innumerable eyes, and innumerable feet. And the Godhead dwelling in every heart is the Third Person, He is Antaryamin, or the Inner Guide.