thanks glenn

this is an other way but not really a question to my current problem.
and i see another problem with this solution.
according to MSDN site, the username property of win32_computersystem is set only for a console session not for a session with terminal service so sometime, i could have no information even if there is a user connected !!!

i had a look to your functions. your WMIAuthentication function is very near from my WMIConnectEx
Except parameters, globally i just see one difference :
your code :
 Code:
$objWBEM=GetObject('winmgmts:{impersonationLevel=impersonate}!\\'+$sComputerName+'\'+$sNameSpace)
my code :
 Code:
$objWMIService=GetObject('winmgmts:{'+$SecuritySettings+'}!\\'+$strcomputer+'\'+$namespace)

I use an optional parameter SecuritySettings where you have hardcoded "impersonationLevel=impersonate".

A word also about the WMIQuery function.
No need to evaluate $sComputer and $root when $pAuth is defined because theses variables aren't used after (and evaluation has already be done by the call to WMIAuthentication).
your code:
 Code:
$sComputer = Trim(Join(Split($sComputer,'\'),''))

If Not $sComputer Or $sComputer = @WKSTA
	$sComputer = '.'
EndIf

If Not $root
	$root = '\root\cimv2'
Endif

If $pAuth
	$SystemSet = $pAuth
Else
	$SystemSet = GetObject('winmgmts:{impersonationLevel=impersonate}!\\' + $sComputer + $root)
	If @ERROR Or Not $SystemSet
		Exit Val('&' + Right(DecToHex(@ERROR), 4))
	EndIf
EndIf
i suggest:
 Code:
If $pAuth
	$SystemSet = $pAuth
Else
	$sComputer = Trim(Join(Split($sComputer,'\'),''))

	If Not $sComputer Or $sComputer = @WKSTA
		$sComputer = '.'
	EndIf

	If Not $root
		$root = '\root\cimv2'
	Endif

	$SystemSet = GetObject('winmgmts:{impersonationLevel=impersonate}!\\' + $sComputer + $root)
	If @ERROR Or Not $SystemSet
		Exit Val('&' + Right(DecToHex(@ERROR), 4))
	EndIf
EndIf

it is compatible with existing code and will execute a little faster when $pAuth is initialized.
_________________________
Christophe