Code:
on @*:JOIN:#channel:{
  ; I opted to use a regex match for checking the nicks
  ; It will match nicks in the form anon### (anon, followed by exactly 3 digits)
  if ($regex($nick,/^anon[\d]{3}$/i)) {
    .notice $nick Please change your nick or you will be kicked after 2 minutes.
    ; Call an additional alias to check if the anon nick is still on the channel
    ; and kick if so
    .timer 1 120 anon.nick.check $nick $chan
  }
}
alias anon.nick.check { if ($1 ison $2) { kick $2 $1 Please change your nick } }


The above code even unedited should have worked most of the time, i have however removed the timername, as this would have caused problems should two nicks mathcing the anon joined, now each join gets a sperate timer to kick them, also I changed the alias to use IF instead of $iif, basicly becuase while it worked the use of $iif in this format is slower and less clear as too what is being done, than using a simple IF, im not saying however personal prefence should be ignored, as its not a task intensive script, so im just showing another option.

alternatively if u were using the below code

Code:
on @*:JOIN:*: {
  if (Anon* iswm $nick) {
     .notice $nick Please change your nick within 2 minutes, or you will be kicked.
    .timer 1 120 if ( $nick ison $chan ) kick $chan $nick Please change your nick
  }
}


I have removed the timername for the same reason here, and added a check to see if $nick (at the time of joining) is still in the channel, if so kick em.