Skip to main content
Kofax

Export KCS user as text file with a script

Article # 3049079 - Page views: 6

Issue

Export KCS user as text file

Cause

To find users with their values more easily.

Solution

UsersAndAddresses Powershell script

- Copy to the KCS server 
- Execute there and specify TXT name
- Log in as a KCS admin
 

KCS export.png

UsersAndAddresses.vbs

Dim Addresses(6)
Addresses(0) = "TOPCALL"
Addresses(1) = "FXI"
Addresses(2) = "MX7"
Addresses(3) = "VOICE"
Addresses(4) = "NOTES"
Addresses(5) = "SMTP"

'---------- insert this code part on top of your VBS file -----
'On Error Resume Next
'Check if it is running on x64 system
Set objShell = CreateObject("WScript.Shell")
Set objArgs = WScript.Arguments
sPlatform = LCase(objShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%"))

If (sPlatform = "amd64") Then
  'We are running the 64 bit version of scripting host - start 32 bit version instead
  'TFC is a 32 bit Dll and requires therefore the 32 bit version of the scripting host
  sCmdLine = Replace(LCase(WScript.FullName), "system32", "SysWOW64") & " """ & WScript.ScriptFullName & """ //NoLogo"
  For iArg = 0 to objArgs.Count - 1 
    sCmdLine = sCmdLine & " """ & objArgs(iArg) & """"
  Next
  'WScript.Echo sCmdLine
  iExitCode = objShell.Run (sCmdLine, 1, True)
  Set objShell = Nothing
  WScript.Quit iExitCode
End If
Set objShell = Nothing
'---------- end of insertion, the real TFC script starts here -----
Do
  sFileName = InputBox("Filename for the user export: ", "KCS User Export", "UserList.txt")
Loop While sFileName = ""

Set objLogin = CreateObject("TCLoginPro.TCLogin")
If objLogin Is Nothing Then
  WScript.Echo "Could not create TC/Login ActiveX Control"
  WScript.Quit -1
End If
objLogin.TFCApplication.ClientType = 0
objLogin.ShowLogin

Set objFSO = CreateObject("Scripting.FileSystemObject") 
If (objFSO is Nothing) Then
  WScript.Echo "Could not create FileSystem Object"
  Set objLogin = Nothing
  WScript.Quit -1
End If 

Set objOutputFile = objFSO.CreateTextFile(sFileName, True, True)
If (objOutputFile is Nothing) Then
  WScript.Echo "Error opening output file " & sFileName
  Set objLogin = Nothing
  WScript.Quit -1
End If

Set objSession = objLogin.MessagingServerSession
If (objSession Is Nothing) Then
  WScript.Echo "Error during login"
  Set objLogin = Nothing
  WScript.Quit -1
End If

Set objUserList = objSession.OpenUserStore ("*")
If (objUserList Is Nothing) Then
  iErr = objSession.LastError
  WScript.Echo "Error opening User Store: " & objSession.LastErrorDescription & "(" & iErr & ")"
  objSession.Logout
  Set objSession = Nothing
  Set objLogin = Nothing
  WScript.Quit iErr
End If

objOutputFile.Write """UserID""" & vbTab & """Salutation""" & vbTab & """Fullname""" &  vbTab & """Department""" & vbTab & """Company""" & vbTab & """FreeText""" & vbTab & """Representative""" & vbTab & """Group""" & vbTab & """Costcenter""" & vbTab & """DirsycAllowed""" & vbTab & """UserBelongsTo""" & vbTab & """DefaultTemplate"""
For j=0 to UBound(Addresses)-1
  objOutputFile.Write vbTab & """Address:" & Addresses(j) & """"
Next
objOutputFile.Write vbCRLF


iCounter = 0
objUserList.First
On Error Resume Next
While (Not objUserList.EOF)
  Set objUserEntry = objUserList.OpenCurrent()
  If objUserEntry Is Nothing Then
    WScript.Echo "Error opening User Profile: " & objSession.LastErrorDescription & "(" & objSession.LastError & ")"
  Else
    sUserID = "" : sUserID = objUserEntry.UserID : objOutputFile.Write """" & sUserID & """"
    Set objUserRecipient = objUserEntry.Recipient
    If objUserRecipient Is Nothing Then
      WScript.Echo "Error getting recipient for user profile: " & sUserID & ": " & objSession.LastErrorDescription & "(" & objSession.LastError & ")"
    Else
      s = ""  : s = objUserRecipient.item("ts_salute")            : objOutputFile.Write vbTab & """" & s & """"
      s = ""  : s = objUserRecipient.item("ts_fullname")          : objOutputFile.Write vbTab & """" & s & """"
      s = ""  : s = objUserRecipient.item("ts_deptm")             : objOutputFile.Write vbTab & """" & s & """"
      s = ""  : s = objUserRecipient.item("ts_company")           : objOutputFile.Write vbTab & """" & s & """"
      s = ""  : s = objUserRecipient.item("ts_freetext")          : objOutputFile.Write vbTab & """" & s & """"
      s = ""  : s = objUserEntry.item("ts_representative")        : objOutputFile.Write vbTab & """" & s & """"
      s = ""  : s = objUserEntry.item("ts_group")                 : objOutputFile.Write vbTab & """" & s & """"
      s = ""  : s = objUserEntry.item("ts_cost_center")           : objOutputFile.Write vbTab & """" & s & """"
      ds = -1 : ds = objUserRecipient.item("int_dirsync_allowed")  
      Select Case (ds)
        Case 0     s = "No"
        Case 255   s = "Yes"
        Case Else  s = ""
      End Select
      objOutputFile.Write vbTab & """" & s & """"
      
      ub = -1 : ub = objUserRecipient.item("int_ownertype")
      Select Case (ub)
        Case 0     s = "Topcall"
        Case 1     s = "MS Mail"
        Case 2     s = "cc:Mail"
        Case 3     s = "Lotus Notes"
        Case 4     s = "HP Open Mail"
        Case 5     s = "Host"
        Case 6     s = "TCFI"
        Case 7     s = "MS Exchange"
        Case 8     s = "Groupwise, Novell Directory Services"
        Case 9     s = "IBM MQ Series"
        Case 10    s = "SAP R/3 via TC/LINK-SC"
        Case 11    s = "SAP R/3 via TC/LINK-AC"
        Case 12    s = "Internet"
        Case 13    s = "SMS"
        Case 14    s = "X.400"
        Case 15    s = "Custom Directory 1"
        Case 16    s = "Custom Directory 2"
        Case 17    s = "Custom Directory 3"
        Case 18    s = "Custom Directory 4"
        Case 19    s = "Custom Directory 5"
        Case 20    s = "Custom Directory 6"
        Case 21    s = "Custom Directory 7"
        Case 22    s = "Custom Directory 8"
        Case 23    s = "Custom Directory 9"
        Case 24    s = "Custom Directory 10"
        Case 25    s = "MFP Connect"
        Case Else  s = ""
      End Select
      objOutputFile.Write vbTab & """" & s & """"
      s = "" : s = objUserEntry.item("un_content.set_client_setup.set_ws_cl_setup.l_setup_ws_client(0).ts_tos_folder") 
      objOutputFile.Write vbTab & """" & s 
      If (s <> "") Then objOutputFile.Write "/"
      s = "" : s = objUserEntry.item("un_content.set_client_setup.set_ws_cl_setup.l_setup_ws_client(0).ts_file_name") 
      objOutputFile.Write s & """"
      
      Set objAddresses = objUserRecipient.Addresses
      If objAddresses Is Nothing Then
        WScript.Echo "Error getting addresses for user profile: " & sUserID & ": " & objSession.LastErrorDescription & "(" & objSession.LastError & ")"
      Else
        For j=0 to UBound(Addresses) - 1
          bFound = False
          For Each objAddress in objAddresses
            If UCase(objAddress.Service) = UCase(Addresses(j)) Then
              objOutputFile.Write vbTab & """" & objAddress.Number & """"
              bFound = True
              Exit For
            End If
          Next
          If Not bFound Then
            objOutputFile.Write vbTab & """"""
          End If
        Next
      End If
    End If
  End If 
  objOutputFile.Write vbCRLF    
  iCounter = iCounter + 1
  objUserList.Next  
Wend    
objOutputFile.Close
WScript.Echo CStr(iCounter) & " User(s) exported to '" & sFileName & "'"
objSession.Logout
 

Level of Complexity 

Easy

Applies to  

Product Version Build Environment Hardware
KCS all      

 

 

Article # 3049079
  • Was this article helpful?