The answer to your question would be that the underlined word that functions as a preposition is <em>of.</em>
Explanation:
The only preposition in the sentence above is <em>of.</em> <em>Machines</em> is a noun, <em>have</em> is functioning as an auxiliary verb. Have + <em>come and gone</em>, behaving as the main verbs form the present perfect tense. Then, <em>but</em> is a conjunction, <em>the </em>is the definite determiner, <em>spirit</em> is a noun as well as <em>invention</em>. Finally, <em>lives</em> is a verb and <em>forever</em> an adverb.