Maybe Im looking at this wrong, but should this...

$ComputerPr = IIf(%XDClientName%,%XDCLientName,@WKSTA)

be this...

$ComputerPr = IIf(%XDClientName%,%XDCLientName%,@WKSTA)

?