List Network Login Profiles
Description
Returns network login information for all the users of a computer.
Supported Platforms
Windows Server 2003 |
Yes |
Windows XP |
Yes |
Windows 2000 |
Yes |
Windows NT 4.0 |
Yes |
Windows 98 |
Yes |
Script Code
On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_NetworkLoginProfile") For Each objItem in colItems dtmWMIDate = objItem.AccountExpires strReturn = WMIDateStringToDate(dtmWMIDate) Wscript.Echo "Account Expires: " & strReturn Wscript.Echo "Authorization Flags: " & objItem.AuthorizationFlags Wscript.Echo "Bad Password Count: " & objItem.BadPasswordCount Wscript.Echo "Caption: " & objItem.Caption Wscript.Echo "CodePage: " & objItem.CodePage Wscript.Echo "Comment: " & objItem.Comment Wscript.Echo "Country Code: " & objItem.CountryCode Wscript.Echo "Description: " & objItem.Description Wscript.Echo "Flags: " & objItem.Flags Wscript.Echo "Full Name: " & objItem.FullName Wscript.Echo "Home Directory: " & objItem.HomeDirectory Wscript.Echo "Home Directory Drive: " & objItem.HomeDirectoryDrive dtmWMIDate = objItem.LastLogoff strReturn = WMIDateStringToDate(dtmWMIDate) Wscript.Echo "Last Logoff: " & strReturn dtmWMIDate = objItem.LastLogon strReturn = WMIDateStringToDate(dtmWMIDate) Wscript.Echo "Last Logon: " & strReturn Wscript.Echo "Logon Hours: " & objItem.LogonHours Wscript.Echo "Logon Server: " & objItem.LogonServer Wscript.Echo "Maximum Storage: " & objItem.MaximumStorage Wscript.Echo "Name: " & objItem.Name Wscript.Echo "Number Of Logons: " & objItem.NumberOfLogons Wscript.Echo "Password Age: " & objItem.PasswordAge dtmWMIDate = objItem.PasswordExpires strReturn = WMIDateStringToDate(dtmWMIDate) Wscript.Echo "Password Expires: " & strReturn Wscript.Echo "Primary Group ID: " & objItem.PrimaryGroupId Wscript.Echo "Privileges: " & objItem.Privileges Wscript.Echo "Profile: " & objItem.Profile Wscript.Echo "Script Path: " & objItem.ScriptPath Wscript.Echo "Setting ID: " & objItem.SettingID Wscript.Echo "Units Per Week: " & objItem.UnitsPerWeek Wscript.Echo "User Comment: " & objItem.UserComment Wscript.Echo "User Id: " & objItem.UserId Wscript.Echo "User Type: " & objItem.UserType Wscript.Echo "Workstations: " & objItem.Workstations Wscript.Echo Next Function WMIDateStringToDate(dtmWMIDate) If Not IsNull(dtmWMIDate) Then WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _ Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _ & " " & Mid (dtmWMIDate, 9, 2) & ":" & _ Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate, 13, 2)) End If End Function
For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.
Disclaimer
This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.