When I run the script below, I get all the names of all the profiles on a remote computer. However, I only get "LastLogon" for Local Users (e.g. "Administrator" and "AspNet"). I do not get "LastLogon" for any domain users who have logged into the remote computer. There is no error message--the result is simply blank.
I am running this script from my own computer--and I am the Domain Admin. My domain username is also part of the administrators group on the remote computer as well.
Does anyone know what might be going wrong?
On Error Resume Next
strComputer = "REMOTECOMPUTER
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile")
For Each objItem in colItems
Wscript.Echo "name: " & objItem.name
Wscript.Echo "LastLogon: " & objItem.LastLogon
Next
I am running this script from my own computer--and I am the Domain Admin. My domain username is also part of the administrators group on the remote computer as well.
Does anyone know what might be going wrong?
On Error Resume Next
strComputer = "REMOTECOMPUTER
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile")
For Each objItem in colItems
Wscript.Echo "name: " & objItem.name
Wscript.Echo "LastLogon: " & objItem.LastLogon
Next