The presence of pathogenic bacteria in water is one of the important health concerns in the world. Herein, we report a new high-performance environmentally friendly poly (urethane-imide) (PUIm) containing β-cyclodextrin (β-CD) in its backbone to adsorb bacteria from water samples with significant heat resistance. New PUIm was prepared by bonding a diisocyanate as a new cross linking agent to β-CD and magnetic nanoparticles (MNPs). The effects of concentrations of bare polymer and polymer bounded to iron nanoparticles and contact times on the adsorption of staphylococcus aureus and Escherichia coli were considered at physiological pH. The adsorption capacity of this polymer is increased by binding it to MNPs and in addition it is possible to separate the polymer from aqueous sample with external magnetic field. A filter was also provided from polymer attached to iron nanoparticles and high percentages of bacteria were removed after filtering the real wastewater