Show current users name on a remote computer

strComputer = "TargetComputerName"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colCSItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objCSItem In colCSItems
WScript.Echo "User Name: " & objCSItem.UserName
Next
Set colOSItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")

No comments:

Recent Posts