To elaborate on what Les suggested, here's some code that might be able to condense things for you a little. I can't really test it though, so i'm not if works or not.

Code:

$DN = TranslateName (3, "", 3, "@Domain\@wksta$", 1)
$DN = $DN[0]
$DN = split($DN,',DC=')[0]
$DN = split($DN,',OU=')
$ubound = ubound($DN)
if $ubound > 1
$computerLoc = $DN[$ubound]
$secondLevel = $DN[$ubound-1]
if $computerLoc = 'HQ'
if instr('BIR;HAT;HFR',$secondLevel)
$computerLoc = $secondLevel
endif
endif
endif
if $computerLoc = 'Metaframe'
$computerLoc = 'CITRIX'
endif
? $computerLoc