'Start of Script ' ********************************************* ' Written for a KB ' used to export users into flat file for extra information ' Scripted update on Feb 17th 2015 ' added more detail about user account and their details. ' to disable all CMD echo's - comment all WScript.Echo within script. ' this will only write to the txt file. ' Disabling the f.WriteLine will stop the output to txt file. ' ' expect run time c:\windows\SysWow64\cscript.exe UserStats.vbs ' version 2 ' Dim fso Set SFTPServer = WScript.CreateObject("SFTPCOMInterface.CIServer") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objLogFile = objFSO.CreateTextFile("output_users.csv", ForWriting , True) ' you need to create the file first ' this assumed that the file will be in the actual directory of where the vbs is running ' start of connection options CRLF = (Chr(13)& Chr(10)) txtServer = "localhost" txtPort = "1100" txtAdminUserName = "test" txtPassword = "test" siteName = "MySite" ' end of connection options If Not Connect(txtServer, txtPort, txtAdminUserName, txtPassword) Then WScript.Quit(0) End If ' chnage the site name to pull only the one that is need, check your spelling, must be exact. set selectedSite = Nothing set sites = SFTPServer.Sites() For i = 0 To sites.Count -1 set site = sites.Item(i) If site.Name = siteName Then set selectedSite = site users = site.GetUsers() Exit For End If Next For each name in users set userSettings = site.GetUserSettings(name) Fullname = userSettings.Fullname Locked = userSettings.IsLocked Phone = userSettings.Phone Fax = userSettings.Fax Pager = userSettings.Pager Email = userSettings.Email Custom1 = userSettings.Custom1 Custom2 = userSettings.Custom2 Custom3 = userSettings.Custom3 Comment = userSettings.Comment PhysHomeDir = site.GetPhysicalPath(name) HomeDirString = userSettings.GetHomeDirString lastModifiedBy = userSettings.LastModifiedBy lastModifiedTime = FormatDateTime(userSettings.LastModificationTime, 1) lastconnectionTime = FormatDateTime(userSettings.LastConnectionTime, 1) accountCreationTime = FormatDateTime(userSettings.AccountCreationTime, 1) objLogFile.Write Fullname & ";" objLogFile.Write name & ";" If userSettings.IsLocked = True Then objLogFile.Write "Locked" & ";" Else objLogFile.Write "UnLocked" & ";" End If If userSettings.GetEnableaccount = True Then objLogFile.Write "Enabled" & ";" Else objLogFile.Write "Disabled" & ";" End If objLogFile.Write Phone & ";" objLogFile.Write Fax & ";" objLogFile.Write Pager & ";" objLogFile.Write Email & ";" objLogFile.Write Custom1 & ";" objLogFile.Write Custom2 & ";" objLogFile.Write Custom3 & ";" objLogFile.Write Comment & ";" objLogFile.Write PhysHomeDir & ";" objLogFile.Write HomeDirString & ";" objLogFile.Write lastModifiedTime objLogFile.Write " by " objLogFile.Write lastModifiedBy & ";" objLogFile.Write lastconnectionTime & ";" objLogFile.Write accountCreationTime & ";" objLogFile.Writeline Next SFTPServer.Close Set SFTPServer = nothing ' eftutils.exe sync users "Kronos Prod>Kronos Prod" /O:CIClientSettings.Username={name} Function Connect (serverOrIpAddress, port, username, password) On Error Resume Next Err.Clear SFTPServer.Connect serverOrIpAddress, port, username, password If Err.Number <> 0 Then f.WriteLine "Error connecting to '" & serverOrIpAddress & ":" & port & "' -- " & err.Description & " [" & CStr(err.Number) & "]", vbInformation, "Error" Connect = False Exit Function End If Connect = True End Function objLogFile.Close 'End of Script