To build a powerful electromagnet, use an iron nail, railroad spike or ferrite rode as a magnetic core. Take 1 inch of the coating from the end of a 22-gauge insulated wire. Use an all-purpose adhesive to attach the wire to the core, and then wrap it around the core from end to end as tightly as possible without the wire overlapping itself. Use the adhesive to attach the other end of the wire to the core.
Take the wire back to the top of the core, and attach it to the top of the new wrapping. Rewrap the rest of the wire over the first set of wrapping in the exact direction as before. Glue it down again, and then bring the wire back up and fasten it to the top. Cut all but 4 inches of wire, and strip the insulation off of an inch of it.
Use fabric tape to wrap the entire magnet in order to protect the magnet's structure and eliminate any debris. Attach the two bare wires to a DC power supply's outputs. The chosen power supply should be no more than 2 amps and approximately 10 volts; anything stronger would risk a fire. Cover exposed wires, and wrap the connection to the outputs with electrical tape. Plug in the power supply to turn on the electromagnet.