:foreach h in=[/ip hotspot host find] do={ :local mac [/ip hotspot host get $h mac-address] :if ([:len [/ip hotspot active find where mac-address=$mac]] = 0) do={ :if ([:len [/ip hotspot user find where name=$mac]] > 0) do={ /ip hotspot host remove $h :local ck [/ip hotspot cookie find where mac-address=$mac] :if ([:len $ck] > 0) do={ /ip hotspot cookie remove $ck } } } }