If you Dim the object variable in the function it will remain local to the function. Otherwise, you can still access the object.

Demonstration...

code:
Break On

GetUserName(@WKSTA) ?

For Each $objComputer in $colComputer
$objComputer.UserName ?
Next

Function GetUserName($sComputer)
;Dim $colComputer
$colComputer = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $sComputer +
"\root\cimv2").ExecQuery("Select * from Win32_ComputerSystem")
For Each $objComputer in $colComputer
$GetUserName = $objComputer.UserName
Next
EndFunction