This is commonly referred to as "dock identification" and is governed by s 45 of the Evidence Act 2006 with further enunciation in Harney v Police  NZSC 107 at –.
Basically, it is considered banned because visual identification has to be conducted according to a "formal procedure", and identification by witnesses in courtrooms falls well short of those formalities.
The only exception is when there is "a good reason for not following a formal procedure" — the scenarios (a)–(f) listed in s 45(4).
Harney v Police adds another "good reason" — in a nut shell it is when the defendant is well known to the witness:
 We are satisfied that where the visual identification evidence
takes the form of a recognition by the eyewitness of someone already
known to the witness ... that can constitute a further good reason for
not following a formal procedure. ... [T]he formal identification
procedures in subs (3) are primarily directed towards identification
of strangers and the risk factors differ with identifications of
persons previously known to the witness. ...
 It does not follow,
of course, that merely because identification evidence takes the form
of recognition of a person known to the defendant, that factor will
necessarily provide a good reason for dispensing with a formal
procedure. It will not do so unless the appearance of the alleged
offender was sufficiently known to the witness before the time of the
alleged offending that a formal procedure would be of no utility. ...
 The sufficiency of the familiarity of the witness with the
defendant's appearance and the utility of a formal procedure need to
be gauged in the individual case. ... There can be, however, no
formulaic requirement, such as that the defendant must have been
"well" known to the witness. The degree of prior contact or knowledge
of appearance, and its sufficiency, must be assessed in each case
taking account of all the circumstances.
In practice, however, parties may have hard times trying to convince the judge that there is (or isn't) a "good reason" to allow dock identification. Given the vagueness of the above passages by the Supreme Court, the rationales for/against dock identification are hard to argue and so are easy to sway either way.