Search This Blog

Wednesday, December 28, 2011

R8.5 Upgrade Project Technical Puzzle

So I'm working on an R6.5 to R8.5 Lotus Notes project the servers are done, for the most part. But now we are having trouble getting final buy-in for upgrading the clients. I have 20,000 of them to do when we get around to doing them, so the pilot has to be OK'ed by the group. I Currently, have 400 pilot clients running some version of R8.5. Some are using the 8.5 Mail template and some are not. And my Project Manager wants to know the following:


How many named PCs in the collection of Pilot are running the latest version of the package?
Who is running Notes R8.5 on that PC, so that we can convert their mailbox to R8?

So, here is what I did...

I made a list of PCs listed in the pilot collection (from SCCM) and put it in a file called workstations.txt

us000001
us000001
mx000001
mx000002
cn000001
cn000002

And, wrote the following code...
===============================================================================
'txtFile = "workstations.txt"
txtFile = "workstationsTest.txt"
const HKEY_LOCAL_MACHINE = &H80000002


'   Lotus Notes 6.5.1 Single Client  {1AAE3976-3167-4BDF-B785-00E19C6671A3}
'   Lotus Notes 6.5.4 Single Client  {6B2764B1-F062-4481-94FD-58B1C211C448}
'   Lotus Notes 8.5.1 Single Client  {6ACD1549-274A-491B-A233-2B8B689DD0D3}
'   Lotus Notes 8.5.1 Multi Client   {836670E9-61EB-4D47-9EF8-CFE936C3FE32}
'   Lotus Notes 8.5.2 Single Client  {E11DFB27-BAF4-46D6-AD76-D5519C0E6786}
'   Lotus Notes 8.5.2 Multi Client   {07C69B3A-62B3-41BF-82EE-B3A87BD6EA0C}
'   Lotus Notes 8.5.3 Single Client  {95246D82-99D2-4229-841E-6867C3251087}


 dim reg(7)
 reg(1)="{07C69B3A-62B3-41BF-82EE-B3A87BD6EA0C}" '   Lotus Notes 8.5.2 Multi Client
 reg(2)="{836670E9-61EB-4D47-9EF8-CFE936C3FE32}" '   Lotus Notes 8.5.1 Multi Client
 reg(3)="{6ACD1549-274A-491B-A233-2B8B689DD0D3}" '   Lotus Notes 8.5.1 Single Client
 reg(4)="{6B2764B1-F062-4481-94FD-58B1C211C448}" '   Lotus Notes 6.5.4 Single Client
 reg(5)="{1AAE3976-3167-4BDF-B785-00E19C6671A3}" '   Lotus Notes 6.5.1 Single Client
 reg(6)="{E11DFB27-BAF4-46D6-AD76-D5519C0E6786}" '   Lotus Notes 8.5.2 Single Client
 reg(7)="{95246D82-99D2-4229-841E-6867C3251087}" '   Lotus Notes 8.5.3 Single Client
 
 
dim txtNotesVersion, txtLastUser, txtPersonName, txtMailServer, txtMailFile
dim txtUserName, count
 
on error resume next 'many PCs will not respond

Dim session, db, view, doc

Set session = CreateObject("Lotus.NotesSession")
Call session.Initialize("xxxxxxxxxxxx")
'wscript.echo "Username: " & session.CommonUserName & "..."
set db = session.getDatabase("HRSM0001/SRV/NA/MyCompanyHub", "names.nsf")
set view =db.getView("lookup\shortname")


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(txtFile, 1)
Do Until objFile.AtEndOfStream
   count = count + 1
   strComputer = objFile.ReadLine
   txtNotesVersion = ReadRegistry(strComputer)
   if len(txtNotesVersion) > 0 then
      txtLastUser = LastUser(strComputer)
      set doc = view.getDocumentByKey(txtLastUser)
      txtPersonName = doc.getItemValue("FullName")
      txtMailServer = doc.getItemValue("MailServer")
      txtMailFile  = doc.getItemValue("MailFile")
   end if
   wscript.echo cstr(count) & ":" & strComputer & ":" & txtNotesVersion & ":" & txtLastUser & ":" & Abbreviate(txtPersonName(0)) & ":" & Abbreviate(txtMailServer(0)) & ":" & txtMailFile(0)
'   wscript.echo cstr(count) & vbTab & strComputer & vbTab & txtNotesVersion & vbTab & txtLastUser & vbTab & Abbreviate(txtPersonName(0)) & vbTab & Abbreviate(txtMailServer(0)) & vbTab & txtMailFile(0)
Loop
objFile.Close
WScript.Quit

 
Function ReadRegistry (strComputer)

   Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
   strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
   strValueName = "DisplayName"
   for i = 1 to 6
      oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath+reg(i),strValueName,strValue
      if len(strValue)>0 then exit for
   next
   ReadRegistry = strValue
end function

function LastUser (strComputer)
   Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
   
   strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon"
   strValueName = "DefaultUserName"
   
   objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
   
   LastUser = strValue

end function

function Abbreviate (txtIn)

   txtIn = replace (txtIn, "CN=", "")
   txtIn = replace (txtIn, "OU=", "")
   txtIn = replace (txtIn, "O=", "")
   
   Abbreviate = txtIn
   
end function

===============================================================================

* You may notice about line 43 (wscript.echo cstr(.... ), uses colons as the delimiter. The next line uses tabs, which I used for importing the data into a spreadsheet.

Which produces the following output...
1:us000001:Lotus Notes 6.5.4:MS000001:Mary Smith/RSM/NA/MyCompany:SRSMM001/SRV/NA/MyCompany:mail\MS000001
2:us000002:Lotus Notes 6.5.4:JJ000002:James Johnson/AMA/NA/MyCompany:SMMOM023/SRV/NA/MyCompany:mail\JJ000002
3:mx000001::MH000001:María Hernández/OAX/NA/MyCompany:SMOXA001/SRV/NA/MyCompany:mail\MH000001
4:mx000002:Lotus Notes 8.5.1:SC000001:Santiago García/OAX/NA/MyCompany:SMOXA001/SRV/NA/MyCompany:mail\SC000001
5:cn000001:Lotus Notes 8.5.2:EL000001:Emma Li/PEI/NA/MyCompany:SMPEI001/SRV/NA/MyCompany:mail\ELi
6:cn000002:Lotus Notes 8.5.1:JL000001:Jacob Lam/PEI/NA/MyCompany:SMPEI001/SRV/NA/MyCompany:mail\JL000001

* Line 3: Turns out Maria's PC does not have Notes installed on it.

Which I pipped to a .txt file for later manipulation and merging with other data sources.