Advertisement
too101

PwC_MS_Standalone_2017 - Internal.vbs

Nov 16th, 2017
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 37.41 KB | None | 0 0
  1. ' ScriptCryptor Project Options Begin
  2. ' HasVersionInfo: No
  3. ' Companyname: PwC
  4. ' Productname: Script - LMCC
  5. ' Filedescription:
  6. ' Copyrights: PwC
  7. ' Trademarks: PwC
  8. ' Originalname:
  9. ' Comments:
  10. ' Productversion:  3. 0. 0. 0
  11. ' Fileversion:  3. 0. 0. 0
  12. ' Internalname:
  13. ' Appicon:
  14. ' AdministratorManifest: No
  15. ' ScriptCryptor Project Options End
  16. 'Option Explicit
  17. '********************************************************************************
  18. '*  Author: Shishir Asati - shishir.asati@in.pwc.com                            *
  19. '*  Purpose: SAM Software Inventory                                             *
  20. '*                                                                              *
  21. Const Version="1.0" '                                                           *
  22. Const ScriptName="PwC_MS_Standalone.vbs"
  23. Const EncryptionEnabled=FALSE
  24. Const LocalModeEnabled=TRUE
  25. PwCMACID=""
  26. PwCHostname=""
  27. CurrentLocation=""
  28. Dim oWMI, oReg
  29. '********************************************************************************
  30.  
  31. '********************************************************************************
  32. '*Featues:  *********************************************************************
  33. '********************************************************************************
  34. 'OS Information
  35. 'Microsoft Specific Installations
  36. 'Event log check
  37. 'SQL Edition check
  38.  
  39. Set objFileSystem = CreateObject("Scripting.fileSystemObject")
  40. Path = Left(WScript.ScriptFullName, InStr(WScript.ScriptFullName, WScript.ScriptName)-1)
  41. ForReading = 1
  42. ForWriting = 2
  43. ForAppending = 8
  44.  
  45.    
  46. If Date <= #2017-03-31# Then
  47.     If Err <> 1 Then
  48.         'MsgBox "Script Started!!!! " & vbNewLine & "Calling System Functions. Please Wait..."
  49.         'ActivationStatus (oWMI)
  50.         'CPUInformation(oWMI)
  51.         'Events(oWMI)
  52.         'Extract_UsersInformation(oWMI)
  53.         'Extracts inventory on a machine
  54.         Inventory(WScript.CreateObject("WScript.Shell").ExpandEnvironmentStrings("%COMPUTERNAME%"))
  55.         'OSInformation(oWMI)
  56.         'SoftwareInformation(objReg)
  57.         End If
  58. Else
  59.     MsgBox "Script Expired!!!" 
  60. End If
  61.  
  62.  
  63.  
  64. Function Inventory(strComputer)
  65.     arrMoniker = Split(strComputer, ";")
  66.     intStart = Now()
  67.    
  68.     'strComputer is either the machine name or a semi-colon delimited string in this format: "machine name;domain\username;password"
  69.     If UBound(arrMoniker) > 0 Then
  70.         On Error Resume Next
  71.         Set oWMI = CreateObject("WbemScripting.SWbemLocator").ConnectServer(arrMoniker(0), "root\CIMV2", arrMoniker(1), arrMoniker(2))  
  72.         On Error Resume Next
  73.         Set oReg = CreateObject("WbemScripting.SWbemLocator").ConnectServer(arrMoniker(0), "root\default", arrMoniker(1), arrMoniker(2)).Get("StdRegProv")  
  74.     Else
  75.         On Error Resume Next
  76.         Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & arrMoniker(0) & "\root\CIMV2")
  77.         On Error Resume Next
  78.         Set oReg = GetObject("winmgmts:\\" & arrMoniker(0) & "\root\default:StdRegProv")
  79.     End If
  80.  
  81.     'Collecting information
  82.     if LocalModeEnabled Then
  83.     tempoutput = MAC(oWMI)
  84.     temoutput = CurrentMachineHostname(oWMI)
  85.     pwcmacidfilename=UCase(arrMoniker(0)) & "_" & PwCMACID
  86.     strOutputFile = Path & "\" & pwcmacidfilename & ".txt"
  87.    
  88.     Else
  89.     strOutputFile = Path & "\" & UCase(arrMoniker(0)) & ".txt"
  90. End If
  91.  
  92.     output = ""
  93.     If Err = 0 Then
  94.         output = output & "### Operating System & Hardware Details ###" & vbCrLf & OSInformation(oWMI)
  95. '       output = output & "### OEM Details ###" & vbCrLf & OEM
  96. '       output = output & "### Windows OS Activation Details ###" & vbCrLf & ActivationStatus(oWMI)
  97. '       output = output & "### CPU Information ###" & vbCrLf & CPUInformation(oWMI)
  98. '       output = output & "### SLMGR ###" & vbCrLf & SLMGR()
  99.         output = output & vbCrLf & "### MAC ###" & vbCrLf & MAC(oWMI)
  100.         output = output & "### Terminal Server Information ###" & vbCrLf & TerminalServiceschk(oWMI)
  101.         output = output & "### Installed Software Application ###" & vbCrLf & SoftwareInformation(oReg)
  102.         output = output & "### Office 2010 License Status###" & Ospp201064bit & vbCrLf
  103.         output = output & "### Office 2010 License Status###" & Ospp201064bit3 & vbCrLf
  104.         output = output & "### Office 2010 License Status###" & Ospp201032bit & vbCrLf
  105.         output = output & "### Office 2010 License Status###" & Ospp201032bit2 & vbCrLf
  106.         output = output & "### Office 2013/365 License Status###" & vbCrLf & Ospp201364bit & vbCrLf
  107.         output = output & "### Office 2013/365 License Status###" & vbCrLf & Ospp201364bit2 & vbCrLf
  108.         output = output & "### Office 2013/365 License Status###" & vbCrLf & Ospp201364bit3 & vbCrLf
  109.         output = output & "### Office 2013/365 License Status###" & vbCrLf & Ospp201332bit & vbCrLf
  110.         output = output & "### Office 2016/365 License Status###" & vbCrLf & Ospp201664bit & vbCrLf
  111.         output = output & "### Office 2016/365 License Status###" & vbCrLf & Ospp201632bit2 & vbCrLf
  112.         output = output & "### Office 2016/365 License Status###" & vbCrLf & Ospp201632bit & vbCrLf
  113.         output = output & "### Office 2016/365 License Status###" & vbCrLf & Ospp201664bit3 & vbCrLf   
  114. '       output = output & "### Logons ###" & vbCrLf & Extract_UsersInformation(oWMI)
  115.         output = output & "### Event Logs ###" & vbCrLf & Events104(oWMI) & vbCrLf
  116.         output = output & "### Event Logs ###" & vbCrLf & Events11707(oWMI) & vbCrLf
  117.         output = output & "### Event Logs ###" & vbCrLf & Events11724(oWMI) & vbCrLf
  118.         output = output & "### Event Logs ###" & vbCrLf & Events592(oWMI) & vbCrLf
  119.         output = output & "### TimeStamps ###" & vbCrLf
  120.         output = output & "Start Time:" & intStart & vbCrLf
  121.         output = output & "End Time:" & Now() & vbCrLf & vbCrLf & vbCrLf
  122.         output = output & "### End of File ###" & vbCrLf
  123.  
  124. if EncryptionEnabled then
  125. output=encrpt(output)
  126. end if
  127.  
  128.     Else
  129.         strOutputFile = Path & "\_Failed_" & UCase(arrMoniker(0)) & ".txt"
  130.         output = Err.Description & " (" & Err.Number & ")"
  131.     End If
  132.     Set reportFile = objFileSystem.OpenTextFile(strOutputFile, ForWriting, true)
  133.     reportFile.WriteLine output
  134.     reportFile.Close
  135.     Err.Clear
  136.  
  137. if LocalModeEnabled then
  138. Set objFSOZ = CreateObject("Scripting.FileSystemObject")
  139. Set objFilez = objFSOZ.GetFile(strOutputFile)
  140.  
  141. 'File size set to 4096 because error messages are 16Bytes long.
  142. if not LogonScriptEnabled then
  143. If objFilez.Size > 4096 Then
  144.     opsize=(objFilez.Size)/1000
  145.     msg = localhostname & " , " & opsize & " KiloBytes" & vbCrLf & vbCrLf & "You may close this window." & vbCrLf
  146.     Wscript.Echo msg
  147. Else
  148.  Wscript.Echo "The file is empty."
  149. End If
  150. end if
  151. end If
  152.  
  153. End Function
  154.  
  155.  
  156. 'Operating System Information
  157. Function OSInformation(oWMI)
  158.  
  159.     On Error Resume Next
  160.     Set colComp = oWMI.InstancesOf("Win32_ComputerSystem")
  161.     For Each objComp In colComp
  162.         On Error Resume Next
  163.         strOutput = strOutput &  "Information;Hostname;Mac ID;Manufacturer;Source;Model;Domain;Is Part of Domain;Current Logged In User;Number of Processors;Operating System;Name;Organization;RegisteredUser;SerialNumber;WindowsDirectory;Version;Original Install Date;OEM Sticker Present?;OS on OEM Sticker;Type of OEM;Location;Model;No of Cores;CPU Manufacturer;No of Logical Processors" & vbCrLf
  164.         strOutput = strOutput & "OS Information" & ";" & objComp.Name & ";" & PwCMACID & ";" & objComp.Manufacturer & ";" & "Semi-Automated" & ";" & objComp.Model & ";" & objComp.Domain & ";" & objComp.PartOfDomain & ";" & objComp.UserName & ";" & objComp.NumberOfProcessors & ";"
  165.     Next
  166.    
  167.     On Error Resume Next
  168.     Set colOS = oWMI.InstancesOf("Win32_OperatingSystem")
  169.     For Each objOS in colOS
  170.         On Error Resume Next
  171.         strOutput = strOutput &  objOS.Caption & ";" & objOS.Name & ";" & objOS.Organization & ";" & objOS.RegisteredUser & ";" & objOS.SerialNumber & ";" & objOS.WindowsDirectory & ";" & objOS.Version & ";" & WMIDateStringToDate(objOS.InstallDate)
  172.    
  173.     Next
  174.    
  175.     On Error Resume Next
  176. dim aname, bname, cname
  177. dname = inputbox("Current Location/Branch of the organization?" & vbCrLf & vbCrLf & "**Do not use any special characters eg: *,%,;,@ etc**", "Location", "NA")
  178. If dname="" Then
  179. MsgBox ("No Input or Invalid Entry!" & vbCrLf & vbCrLf & "Script will not proceed further")
  180. WScript.Quit
  181. End if
  182.  
  183. aname = inputbox("Is there any OEM (Yes or No)?" & vbCrLf & vbCrLf & "**Do not use any special characters eg: *,%,;,@ etc**", "OEM Information", "NA")
  184. If aname="" Then
  185. MsgBox ("No Input or Invalid Entry!" & vbCrLf & vbCrLf & "Script will not proceed further")
  186. WScript.Quit
  187. End If
  188.  
  189. bname = inputbox("OS on OEM Sticker? (Type 'NA' incase of No OEM)" & vbCrLf & vbCrLf & "**Do not use any special characters eg: *,%,;,@ etc**", "OEM Information", "NA")
  190. If bname="" Then
  191. MsgBox ("No Input or Invalid Entry!" & vbCrLf & vbCrLf & "Script will not proceed further")
  192. WScript.Quit
  193. End if
  194.  
  195.  
  196. cname = inputbox("Direct or Channel? (Type 'NA' incase of No OEM)" & vbCrLf & vbCrLf & "**Do not use any special characters eg: *,%,;,@ etc**", "OEM Information", "NA")
  197. If cname="" Then
  198. MsgBox ("No Input or Invalid Entry!" & vbCrLf & vbCrLf & "Script will not proceed further")
  199. WScript.Quit
  200. End if
  201.  
  202. strOutput = strOutput & ";" & aname & ";" & bname & ";" & cname & ";" & dname
  203. CurrentLocation = dname
  204.         'Next
  205.        
  206.         On Error Resume Next
  207.     Set colCPU = oWMI.InstancesOf("Win32_Processor")
  208.         For Each objCPU in colCPU
  209.         strOutput = strOutput & ";" & objCPU.Name & ";" & objCPU.NumberOfCores  & ";" & objCPU.Manufacturer & "; " & objCPU.NumberOfLogicalProcessors & vbCrLf
  210.         On Error Resume Next
  211.  
  212. Next
  213.    
  214.     On Error Resume Next
  215. Dim ObjExec
  216. Dim strFromProc
  217. Dim SystemRoot
  218.  
  219. Set objShell = WScript.CreateObject("WScript.Shell")
  220. SystemRoot = wshShell.ExpandEnvironmentStrings("%SystemRoot%")
  221. Set ObjExec = objShell.Exec("Cscript //Nologo %SystemRoot%\system32\slmgr.vbs /dli")
  222. On Error Resume Next
  223.  
  224. Do
  225.     strFromProc = ObjExec.StdOut.ReadLine()
  226.     Stroutput= Stroutput & ";" & strFromProc
  227. Loop While Not ObjExec.Stdout.AtEndOfStream
  228. On Error Resume Next
  229.        
  230.         If Err <> 0 Then
  231.             strOutput = strOutput & Err.Description & vbCrLf
  232.             Err.Clear
  233.         End If
  234.     'Next
  235.    
  236.     If Err <> 0 Then
  237.         strOutput = strOutput & Err.Description & vbCrLf
  238.         Err.Clear
  239.     End If
  240.     OSInformation = strOutput & vbCrLf
  241.     'Next
  242. End Function
  243.  
  244. '64 bit
  245. Function Ospp201032bit
  246.  
  247. Dim ObjExec
  248. Dim strFromProc
  249.  
  250. Set objShell = WScript.CreateObject("WScript.Shell")
  251. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~2\Micros~1\Office14\Ospp.vbs /dstatus")
  252. On Error Resume Next
  253.  
  254. Do
  255.     strFromProc = ObjExec.StdOut.ReadLine()
  256.     Stroutput= Stroutput & vbCrLf & strFromProc
  257. Loop While Not ObjExec.Stdout.AtEndOfStream
  258. On Error Resume Next
  259.    
  260.         If Err <> 0 Then
  261.             strOutput = strOutput & Err.Description & vbCrLf
  262.             Err.Clear
  263.         End If
  264.     'Next
  265.    
  266.     If Err <> 0 Then
  267.         strOutput = strOutput & Err.Description & vbCrLf
  268.         Err.Clear
  269.     End If
  270.     Ospp201032bit = strOutput & vbCrLf
  271.     'Next
  272.    
  273. End Function
  274.  
  275.  
  276. '64 bit Parse 2
  277. Function Ospp201032bit2
  278.  
  279. Dim ObjExec
  280. Dim strFromProc
  281.  
  282. Set objShell = WScript.CreateObject("WScript.Shell")
  283. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~2\Micros~2\Office14\Ospp.vbs /dstatus")
  284. On Error Resume Next
  285.  
  286. Do
  287.     strFromProc = ObjExec.StdOut.ReadLine()
  288.     Stroutput= Stroutput & vbCrLf & strFromProc
  289. Loop While Not ObjExec.Stdout.AtEndOfStream
  290. On Error Resume Next
  291.    
  292.         If Err <> 0 Then
  293.             strOutput = strOutput & Err.Description & vbCrLf
  294.             Err.Clear
  295.         End If
  296.     'Next
  297.    
  298.     If Err <> 0 Then
  299.         strOutput = strOutput & Err.Description & vbCrLf
  300.         Err.Clear
  301.     End If
  302.     Ospp201032bit2 = strOutput & vbCrLf
  303.     'Next
  304.    
  305. End Function
  306.  
  307.  
  308. '32 bit
  309. Function Ospp201064bit
  310.  
  311. Dim ObjExec
  312. Dim strFromProc
  313.  
  314. Set objShell = WScript.CreateObject("WScript.Shell")
  315. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~1\Micros~1\Office14\Ospp.vbs /dstatus")
  316. On Error Resume Next
  317.  
  318. Do
  319.     strFromProc = ObjExec.StdOut.ReadLine()
  320.     Stroutput= Stroutput & vbCrLf & strFromProc
  321. Loop While Not ObjExec.Stdout.AtEndOfStream
  322. On Error Resume Next
  323.    
  324.         If Err <> 0 Then
  325.             strOutput = strOutput & Err.Description & vbCrLf
  326.             Err.Clear
  327.         End If
  328.     'Next
  329.    
  330.     If Err <> 0 Then
  331.         strOutput = strOutput & Err.Description & vbCrLf
  332.         Err.Clear
  333.     End If
  334.     Ospp201064bit = strOutput & vbCrLf
  335.     'Next
  336.    
  337. End Function
  338.  
  339.  
  340.  
  341. '32 bit Parse 3
  342. Function Ospp201064bit3
  343.  
  344. Dim ObjExec
  345. Dim strFromProc
  346.  
  347. Set objShell = WScript.CreateObject("WScript.Shell")
  348. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~1\Micros~1\Office14\Ospp.vbs /dstatus")
  349. On Error Resume Next
  350.  
  351. Do
  352.     strFromProc = ObjExec.StdOut.ReadLine()
  353.     Stroutput= Stroutput & vbCrLf & strFromProc
  354. Loop While Not ObjExec.Stdout.AtEndOfStream
  355. On Error Resume Next
  356.    
  357.         If Err <> 0 Then
  358.             strOutput = strOutput & Err.Description & vbCrLf
  359.             Err.Clear
  360.         End If
  361.     'Next
  362.    
  363.     If Err <> 0 Then
  364.         strOutput = strOutput & Err.Description & vbCrLf
  365.         Err.Clear
  366.     End If
  367.     Ospp201064bit3 = strOutput & vbCrLf
  368.     'Next
  369.    
  370. End Function
  371.  
  372.  
  373. '64 bit
  374. Function Ospp201332bit
  375.  
  376. Dim ObjExec
  377. Dim strFromProc
  378.  
  379. Set objShell = WScript.CreateObject("WScript.Shell")
  380. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~2\Micros~1\Office15\Ospp.vbs /dstatus")
  381. On Error Resume Next
  382.  
  383. Do
  384.     strFromProc = ObjExec.StdOut.ReadLine()
  385.     Stroutput= Stroutput & vbCrLf & strFromProc
  386. Loop While Not ObjExec.Stdout.AtEndOfStream
  387. On Error Resume Next
  388.    
  389.         If Err <> 0 Then
  390.             strOutput = strOutput & Err.Description & vbCrLf
  391.             Err.Clear
  392.         End If
  393.     'Next
  394.    
  395.     If Err <> 0 Then
  396.         strOutput = strOutput & Err.Description & vbCrLf
  397.         Err.Clear
  398.     End If
  399.     Ospp201332bit = strOutput & vbCrLf
  400.     'Next
  401.    
  402. End Function
  403.  
  404.  
  405. '32 bit
  406. Function Ospp201364bit
  407.  
  408. Dim ObjExec
  409. Dim strFromProc
  410.  
  411. Set objShell = WScript.CreateObject("WScript.Shell")
  412. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~1\Micros~1\Office15\Ospp.vbs /dstatus")
  413. On Error Resume Next
  414.  
  415. Do
  416.     strFromProc = ObjExec.StdOut.ReadLine()
  417.     Stroutput= Stroutput & vbCrLf & strFromProc
  418. Loop While Not ObjExec.Stdout.AtEndOfStream
  419. On Error Resume Next
  420.    
  421.         If Err <> 0 Then
  422.             strOutput = strOutput & Err.Description & vbCrLf
  423.             Err.Clear
  424.         End If
  425.     'Next
  426.    
  427.     If Err <> 0 Then
  428.         strOutput = strOutput & Err.Description & vbCrLf
  429.         Err.Clear
  430.     End If
  431.     Ospp201364bit = strOutput & vbCrLf
  432.     'Next
  433.    
  434. End Function
  435.  
  436.  
  437. '32 bit - Parse2
  438. Function Ospp201364bit2
  439.  
  440. Dim ObjExec
  441. Dim strFromProc
  442.  
  443. Set objShell = WScript.CreateObject("WScript.Shell")
  444. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~1\Micros~2\Office15\Ospp.vbs /dstatus")
  445. On Error Resume Next
  446.  
  447. Do
  448.     strFromProc = ObjExec.StdOut.ReadLine()
  449.     Stroutput= Stroutput & vbCrLf & strFromProc
  450. Loop While Not ObjExec.Stdout.AtEndOfStream
  451. On Error Resume Next
  452.    
  453.         If Err <> 0 Then
  454.             strOutput = strOutput & Err.Description & vbCrLf
  455.             Err.Clear
  456.         End If
  457.     'Next
  458.    
  459.     If Err <> 0 Then
  460.         strOutput = strOutput & Err.Description & vbCrLf
  461.         Err.Clear
  462.     End If
  463.     Ospp201364bit2 = strOutput & vbCrLf
  464.     'Next
  465.    
  466. End Function
  467.  
  468.  
  469.  
  470. '32 bit - Parse3
  471. Function Ospp201364bit3
  472.  
  473. Dim ObjExec
  474. Dim strFromProc
  475.  
  476. Set objShell = WScript.CreateObject("WScript.Shell")
  477. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~2\Micros~2\Office15\Ospp.vbs /dstatus")
  478. On Error Resume Next
  479.  
  480. Do
  481.     strFromProc = ObjExec.StdOut.ReadLine()
  482.     Stroutput= Stroutput & vbCrLf & strFromProc
  483. Loop While Not ObjExec.Stdout.AtEndOfStream
  484. On Error Resume Next
  485.    
  486.         If Err <> 0 Then
  487.             strOutput = strOutput & Err.Description & vbCrLf
  488.             Err.Clear
  489.         End If
  490.     'Next
  491.    
  492.     If Err <> 0 Then
  493.         strOutput = strOutput & Err.Description & vbCrLf
  494.         Err.Clear
  495.     End If
  496.     Ospp201364bit3 = strOutput & vbCrLf
  497.     'Next
  498.    
  499. End Function
  500.  
  501.  
  502. '64 bit
  503. Function Ospp201632bit
  504.  
  505. Dim ObjExec
  506. Dim strFromProc
  507.  
  508. Set objShell = WScript.CreateObject("WScript.Shell")
  509. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~2\Micros~1\Office16\Ospp.vbs /dstatus")
  510. On Error Resume Next
  511.  
  512. Do
  513.     strFromProc = ObjExec.StdOut.ReadLine()
  514.     Stroutput= Stroutput & vbCrLf & strFromProc
  515. Loop While Not ObjExec.Stdout.AtEndOfStream
  516. On Error Resume Next
  517.    
  518.         If Err <> 0 Then
  519.             strOutput = strOutput & Err.Description & vbCrLf
  520.             Err.Clear
  521.         End If
  522.     'Next
  523.    
  524.     If Err <> 0 Then
  525.         strOutput = strOutput & Err.Description & vbCrLf
  526.         Err.Clear
  527.     End If
  528.     Ospp201632bit = strOutput & vbCrLf
  529.     'Next
  530.    
  531. End Function
  532.  
  533.  
  534. '64 bit Parse 2
  535. Function Ospp201632bit2
  536.  
  537. Dim ObjExec
  538. Dim strFromProc
  539.  
  540. Set objShell = WScript.CreateObject("WScript.Shell")
  541. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~2\Micros~2\Office16\Ospp.vbs /dstatus")
  542. On Error Resume Next
  543.  
  544. Do
  545.     strFromProc = ObjExec.StdOut.ReadLine()
  546.     Stroutput= Stroutput & vbCrLf & strFromProc
  547. Loop While Not ObjExec.Stdout.AtEndOfStream
  548. On Error Resume Next
  549.    
  550.         If Err <> 0 Then
  551.             strOutput = strOutput & Err.Description & vbCrLf
  552.             Err.Clear
  553.         End If
  554.     'Next
  555.    
  556.     If Err <> 0 Then
  557.         strOutput = strOutput & Err.Description & vbCrLf
  558.         Err.Clear
  559.     End If
  560.     Ospp201632bit2 = strOutput & vbCrLf
  561.     'Next
  562.    
  563. End Function
  564.  
  565.  
  566.  
  567.  
  568. '32 bit
  569. Function Ospp201664bit
  570.  
  571. Dim ObjExec
  572. Dim strFromProc
  573.  
  574. Set objShell = WScript.CreateObject("WScript.Shell")
  575. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~1\Micros~1\Office16\Ospp.vbs /dstatus")
  576. On Error Resume Next
  577.  
  578. Do
  579.     strFromProc = ObjExec.StdOut.ReadLine()
  580.     Stroutput= Stroutput & vbCrLf & strFromProc
  581. Loop While Not ObjExec.Stdout.AtEndOfStream
  582. On Error Resume Next
  583.    
  584.         If Err <> 0 Then
  585.             strOutput = strOutput & "Not Found" & vbCrLf
  586.             Err.Clear
  587.         End If
  588.     'Next
  589.    
  590.     If Err <> 0 Then
  591.         strOutput = strOutput & "Not Found" & vbCrLf
  592.         Err.Clear
  593.     End If
  594.     Ospp201664bit = strOutput & vbCrLf
  595.     'Next
  596.    
  597. End Function
  598.  
  599.  
  600. '32 bit Parse 3
  601. Function Ospp201664bit3
  602.  
  603. Dim ObjExec
  604. Dim strFromProc
  605.  
  606. Set objShell = WScript.CreateObject("WScript.Shell")
  607. Set ObjExec = objShell.Exec("Cscript //Nologo C:\Progra~1\Micros~2\Office16\Ospp.vbs /dstatus")
  608. On Error Resume Next
  609.  
  610. Do
  611.     strFromProc = ObjExec.StdOut.ReadLine()
  612.     Stroutput= Stroutput & vbCrLf & strFromProc
  613. Loop While Not ObjExec.Stdout.AtEndOfStream
  614. On Error Resume Next
  615.    
  616.         If Err <> 0 Then
  617.             strOutput = strOutput & "Not Found" & vbCrLf
  618.             Err.Clear
  619.         End If
  620.     'Next
  621.    
  622.     If Err <> 0 Then
  623.         strOutput = strOutput & "Not Found" & vbCrLf
  624.         Err.Clear
  625.     End If
  626.     Ospp201664bit3 = strOutput & vbCrLf
  627.     'Next
  628.    
  629. End Function
  630.  
  631.  
  632.  
  633.  
  634. ' MAC Address
  635. Function MAC(oWMI)
  636. On Error Resume Next
  637. Set colItems = oWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled = True")
  638.  
  639. For Each objItem in colItems
  640.  
  641.     strOutput = strOutput & "MAC Address: " & objItem.MACAddress & vbCrLf
  642.     strOutput = strOutput & "DHCP Enabled: " & objItem.DHCPEnabled & vbCrLf
  643.     PwCMACID=macidtostring(objItem.MACAddress)
  644.         If Err <> 0 Then
  645.             strOutput = strOutput & Err.Description & vbCrLf
  646.             Err.Clear
  647.         End If
  648.     Next
  649.    
  650.     If Err <> 0 Then
  651.         strOutput = strOutput & Err.Description & vbCrLf
  652.         Err.Clear
  653.     End If
  654.     MAC = strOutput & vbCrLf
  655.    
  656. End Function
  657.  
  658.  
  659. Function CurrentMachineHostname(oWMI)
  660. On Error Resume Next
  661.  
  662.     Set colComp = oWMI.InstancesOf("Win32_ComputerSystem")
  663.     For Each objComp In colComp
  664.         On Error Resume Next
  665.         PwCHostname=objComp.Name
  666.                
  667.     Next
  668. End Function
  669.  
  670.  
  671.  
  672. ' Terminal Services Check
  673. Function TerminalServiceschk(oWMI)
  674. On Error Resume Next
  675.     Set colWPA = oWMI.InstancesOf("Win32_TerminalService")
  676.    
  677.     For Each objWPA In colWPA
  678.         On Error Resume Next
  679.         strOutput = strOutput &  "Information;Hostname;Location;Service Name;Caption;Desktop Interact;Service Started;State;Status;Host System Name;Start Name; Total Sessions;No of Disconnected Sessions" & vbCrLf
  680.         strOutput = strOutput & "TerminalServices" & ";" & PwCHostname & ";" & CurrentLocation & ";" & objWPA.DisplayName & ";" & objWPA.Name & ";" & objWPA.DesktopInteract & ";" & ";" & objWPA.Started & ";" & objWPA.State & ";" & objWPA.Status & ";" & objWPA.SystemName & ";" & objWPA.StartName & ";" & objWPA.TotalSessions & ";" & objWPA.DisconnectedSessions & vbCrLf
  681.        
  682.         If Err <> 0 Then
  683.             strOutput = strOutput & Err.Description & vbCrLf
  684.             Err.Clear
  685.         End If
  686.     Next
  687.    
  688.     If Err <> 0 Then
  689.         strOutput = strOutput & Err.Description & vbCrLf
  690.         Err.Clear
  691.     End If
  692.     TerminalServiceschk = strOutput & vbCrLf
  693.    
  694. End Function
  695.  
  696.  
  697. 'software information
  698. Function SoftwareInformation(objReg)
  699.  
  700.     strOutput = "Information;Hostname;Installed Applications;Source;Location;Install Date;Version Major;Version Minor;Size;Publisher" & vbCrLf
  701.     strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
  702.     strKey32 = "SOFTWARE\wow6432node\Microsoft\Windows\CurrentVersion\Uninstall\"
  703.     HKLM = &H80000002 'HKEY_LOCAL_MACHINE
  704.     FoundSQLServer = False
  705.    
  706.     'Default location for 32bit and 64bit programs
  707.     On Error Resume Next
  708.     objReg.EnumKey HKLM, strKey, arrSubkeys
  709.     For Each strSubkey In arrSubkeys
  710.         intName = objReg.GetStringValue(HKLM, strKey & strSubkey, "DisplayName", strName)
  711.     ' Process only products whose name contain 'Microsoft'
  712.         If InStr(1, strName, "Microsoft", vbTextCompare) > 0 Then
  713.         objReg.GetDWORDValue HKLM, strKey & strSubkey, "VersionMajor", intVersionMajor
  714.         objReg.GetDWORDValue HKLM, strKey & strSubkey, "VersionMinor", intVersionMinor
  715.         objReg.GetStringValue HKLM, strKey & strSubkey, "InstallDate", strDate
  716.         objReg.GetDWORDValue HKLM, strKey & strSubkey, "EstimatedSize", intSize
  717.         objReg.GetStringValue HKLM, strKey & strSubkey, "Publisher", strPublisher
  718.         strOutput = strOutput & "InstalledApp" & ";" & PwCHostname & ";" & strName & ";" & "Semi-Automated" & ";" & CurrentLocation & ";" & strDate & ";" & intVersionMajor & ";" & intVersionMinor & ";" & intSize & ";" & strPublisher & vbCrLf
  719.         End If
  720.         If intName <> 0 Then
  721.         objReg.GetStringValue HKLM, strKey & strSubkey, "QuietDisplayName", strName
  722.         End If
  723.         If InStr(strName, "SQL") > 0 Then
  724.             FoundSQLServer = True
  725.         End If
  726.         Next
  727.     If Err <> 0 Then
  728.         strOutput = strOutput & Err.Description & vbCrLf
  729.         Err.Clear
  730.     End If
  731.  
  732.     'Additional location for 32bit programs on 64bit OS
  733.     On Error Resume Next
  734.     objReg.EnumKey HKLM, strKey32, arrSubkeys
  735.     For Each strSubkey In arrSubkeys
  736.         intName = objReg.GetStringValue(HKLM, strKey32 & "\" & strSubkey, "DisplayName", strName)
  737.     ' Process only products whose name contain 'Microsoft'
  738.         If InStr(1, strName, "Microsoft", vbTextCompare) > 0 Then
  739.         objReg.GetDWORDValue HKLM, strKey32 & strSubkey, "VersionMajor", intVersionMajor
  740.         objReg.GetDWORDValue HKLM, strKey32 & strSubkey, "VersionMinor", intVersionMinor
  741.         objReg.GetStringValue HKLM, strKey32 & strSubkey, "InstallDate", strDate
  742.         objReg.GetDWORDValue HKLM, strKey32 & strSubkey, "EstimatedSize", intSize
  743.         objReg.GetStringValue HKLM, strKey32 & strSubkey, "Publisher", strPublisher
  744.         strOutput = strOutput & "InstalledApp" & ";" & PwCHostname & ";" & strName & ";" & "Semi-Automated" & ";" & CurrentLocation & ";" & strDate & ";" & intVersionMajor & ";" & intVersionMinor & ";" & intSize & ";" & strPublisher & vbCrLf
  745.     'strOutput = strOutput & "InstalledApp" & ";" & PwCHostname & ";" & CurrentLocation & ";" & strName & ";" & "Semi-Automated" & ";" & intVersionMajor & ";" & intVersionMinor & ";" & strDate & ";" & intSize & ";" & strPublisher & vbCrLf
  746.         End If
  747.         If intName <> 0 Then
  748.         objReg.GetStringValue HKLM, strKey32 & strSubkey, "QuietDisplayName", strName
  749.         End If
  750.         If InStr(strName, "Microsoft SQL Server") > 0 Then
  751.             FoundSQLServer = True
  752.         End If
  753.     Next
  754.     If Err <> 0 Then
  755.         Err.Clear
  756.     End If
  757.  
  758.     If FoundSQLServer Then
  759.         strSQL = SQLInformation(objReg, False)
  760.         strSQL32 = SQLInformation(objReg, True)
  761.         If strSQL <> "" Or strSQL32 <> "" Then
  762.             strOutput = strOutput & vbCrLf & "### SQL Server - Additional Information ###" & vbCrLf & strSQL & strSQL32
  763.         End If
  764.        
  765.     End If
  766.     SoftwareInformation = strOutput & vbCrLf
  767.  
  768. End Function
  769.  
  770.  
  771. 'SQL Server edition, version, components and clustering information
  772. Function SQLInformation(objReg, check32)
  773.    
  774.     strOutput = ""
  775.     strWow6432node = ""
  776.     If check32 Then
  777.         strWow6432node = "\wow6432node"
  778.     End If
  779.    
  780.     'Checking for SQL Database Engine 2000
  781.     objReg.EnumValues , "SOFTWARE" & strWow6432node & "\Microsoft\MSSQLServer\Setup", arrValueNames, arrValueTypes
  782.     If Not IsNull(arrValueNames) Then
  783.         strEdition = ""
  784.         strVersion = ""
  785.         intCluster = ""
  786.         strPath = ""
  787.         For i = 0 To UBound(arrValueNames)
  788.             If arrValueNames(i) = "Edition" Then
  789.                 objReg.GetStringValue ,"SOFTWARE" & strWow6432node & "\Microsoft\MSSQLServer\Setup",arrValueNames(i) ,strEdition
  790.             ElseIf arrValueNames(i) = "Patchlevel" Then
  791.                 objReg.GetStringValue ,"SOFTWARE" & strWow6432node & "\Microsoft\MSSQLServer\Setup",arrValueNames(i) ,strVersion
  792.             ElseIf arrValueNames(i) = "SqlCluster" Then
  793.                 objReg.GetDWORDValue ,"SOFTWARE" & strWow6432node & "\Microsoft\MSSQLServer\Setup",arrValueNames(i) ,intCluster
  794.             ElseIf arrValueNames(i) = "SQLPath" Then
  795.                 objReg.GetStringValue ,"SOFTWARE" & strWow6432node & "\Microsoft\MSSQLServer\Setup",arrValueNames(i) ,strPath
  796.             End If
  797.         Next
  798.         If strEdition <> "" And strVersion <> "" Then
  799.             strOutput = strOutput & "SQL Edition:" & strEdition & vbCrLf
  800.             strOutput = strOutput & "SQL Version:" & strVersion & vbCrLf
  801.             strOutput = strOutput & "SQL Clustering:" & intCluster & vbCrLf
  802.             strOutput = strOutput & "SQL Install Directory:" & strPath & vbCrLf
  803.         End If
  804.         arrValueNames = Array()
  805.         arrValueTypes = Array()
  806.     End If 
  807.    
  808.     'Checking for SQL Database Engine 2005, 2008 and 2008R2
  809.     objReg.EnumValues , "Software" & strWow6432node & "\Microsoft\Microsoft SQL Server\Instance Names\SQL", arrSQLValueNames, arrSQLValueTypes
  810.     If Not IsNull(arrSQLValueNames) Then
  811.         For i = 0 To UBound(arrSQLValueNames)
  812.             'Extracting for each SQL Server instance, the registry path
  813.             strSQLPath = ""
  814.             objReg.GetStringValue , "Software" & strWow6432node & "\Microsoft\Microsoft SQL Server\Instance Names\SQL", arrSQLValueNames(i), strSQLPath
  815.             strSQLPath = "Software" & strWow6432node & "\Microsoft\Microsoft SQL Server\" & strSQLPath & "\Setup"
  816.  
  817.             'Extracting for each SQL Server instance, the setup keys and values
  818.             objReg.EnumValues , strSQLPath, arrValueNames, arrValueTypes
  819.             strEdition = ""
  820.             strVersion = ""
  821.             intCluster = ""
  822.             strPath = ""
  823.             For j = 0 To UBound(arrValueNames)
  824.                 If arrValueNames(j) = "Edition" Then
  825.                     objReg.GetStringValue , strSQLPath, arrValueNames(j), strEdition
  826.                 ElseIf arrValueNames(j) = "Version" Then
  827.                     objReg.GetStringValue , strSQLPath, arrValueNames(j), strVersion
  828.                 ElseIf arrValueNames(j) = "SqlCluster" Then
  829.                     objReg.GetDWORDValue , strSQLPath, arrValueNames(j), intCluster
  830.                 ElseIf arrValueNames(j) = "SQLPath" Then
  831.                     objReg.GetStringValue , strSQLPath, arrValueNames(j), strPath
  832.                 End If
  833.             Next
  834.             If strEdition <> "" And strVersion <> "" Then
  835.                 strOutput = strOutput & "SQL Edition:" & strEdition & vbCrLf
  836.                 strOutput = strOutput & "SQL Version:" & strVersion & vbCrLf
  837.                 strOutput = strOutput & "SQL Clustering:" & intCluster & vbCrLf
  838.                 strOutput = strOutput & "SQL Install Directory:" & strPath & vbCrLf
  839.             End If
  840.             arrValueNames = Array()
  841.             arrValueTypes = Array()            
  842.         Next
  843.         arrSQLValueNames = Array()
  844.         arrSQLValueTypes = Array() 
  845.     End If
  846.    
  847.     'Checking for SQL Analysis Services 2005, 2008 and 2008R2
  848.     objReg.EnumValues , "Software" & strWow6432node & "\Microsoft\Microsoft SQL Server\Instance Names\OLAP", arrSQLValueNames, arrSQLValueTypes
  849.     If Not IsNull(arrSQLValueNames) Then
  850.         For i = 0 To UBound(arrSQLValueNames)
  851.             'Extracting for each SQL Server instance, the registry path
  852.             strSQLPath = ""
  853.             objReg.GetStringValue , "Software" & strWow6432node & "\Microsoft\Microsoft SQL Server\Instance Names\OLAP", arrSQLValueNames(i), strSQLPath
  854.             strSQLPath = "Software" & strWow6432node & "\Microsoft\Microsoft SQL Server\" & strSQLPath & "\Setup"
  855.  
  856.             'Extracting for each SQL Server instance, the setup keys and values
  857.             objReg.EnumValues , strSQLPath, arrValueNames, arrValueTypes
  858.             strEdition = ""
  859.             strVersion = ""
  860.             intCluster = ""
  861.             strPath = ""
  862.             For j = 0 To UBound(arrValueNames)
  863.                 If arrValueNames(j) = "Edition" Then
  864.                     objReg.GetStringValue , strSQLPath, arrValueNames(j), strEdition
  865.                 ElseIf arrValueNames(j) = "Version" Then
  866.                     objReg.GetStringValue , strSQLPath, arrValueNames(j), strVersion
  867.                 ElseIf arrValueNames(j) = "SqlCluster" Then
  868.                     objReg.GetDWORDValue , strSQLPath, arrValueNames(j), intCluster
  869.                 ElseIf arrValueNames(j) = "SQLPath" Then
  870.                     objReg.GetStringValue , strSQLPath, arrValueNames(j), strPath
  871.                 End If
  872.             Next
  873.             If strEdition <> "" And strVersion <> "" Then
  874.                 strOutput = strOutput & "Analysis;" & strEdition & ";" & strVersion & ";" & intCluster & ";" & strPath & vbCrLf
  875.             End If
  876.             arrValueNames = Array()
  877.             arrValueTypes = Array()            
  878.         Next
  879.         arrSQLValueNames = Array()
  880.         arrSQLValueTypes = Array() 
  881.     End If
  882.        
  883.     'Checking for SQL Reporting Services 2005, 2008 and 2008R2
  884.     objReg.EnumValues , "Software" & strWow6432node & "\Microsoft\Microsoft SQL Server\Instance Names\RS", arrSQLValueNames, arrSQLValueTypes
  885.     If Not IsNull(arrSQLValueNames) Then
  886.         For i = 0 To UBound(arrSQLValueNames)
  887.             'Extracting for each SQL Server instance, the registry path
  888.             strSQLPath = ""
  889.             objReg.GetStringValue , "Software" & strWow6432node & "\Microsoft\Microsoft SQL Server\Instance Names\RS", arrSQLValueNames(i), strSQLPath
  890.             strSQLPath = "Software" & strWow6432node & "\Microsoft\Microsoft SQL Server\" & strSQLPath & "\Setup"
  891.  
  892.             'Extracting for each SQL Server instance, the setup keys and values
  893.             objReg.EnumValues , strSQLPath, arrValueNames, arrValueTypes
  894.             strEdition = ""
  895.             strVersion = ""
  896.             intCluster = ""
  897.             strPath = ""
  898.             For j = 0 To UBound(arrValueNames)
  899.                 If arrValueNames(j) = "Edition" Then
  900.                     objReg.GetStringValue , strSQLPath, arrValueNames(j), strEdition
  901.                 ElseIf arrValueNames(j) = "Version" Then
  902.                     objReg.GetStringValue , strSQLPath, arrValueNames(j), strVersion
  903.                 ElseIf arrValueNames(j) = "SqlCluster" Then
  904.                     objReg.GetDWORDValue , strSQLPath, arrValueNames(j), intCluster
  905.                 ElseIf arrValueNames(j) = "SQLPath" Then
  906.                     objReg.GetStringValue , strSQLPath, arrValueNames(j), strPath
  907.                 End If
  908.             Next
  909.             If strEdition <> "" And strVersion <> "" Then
  910.                 strOutput = strOutput & "Reporting;" & strEdition & ";" & strVersion & ";" & intCluster & ";" & strPath & vbCrLf
  911.             End If
  912.             arrValueNames = Array()
  913.             arrValueTypes = Array()            
  914.         Next
  915.         arrSQLValueNames = Array()
  916.         arrSQLValueTypes = Array() 
  917.     End If
  918.    
  919.     'Checking for SQL Integration Services 2005
  920.     objReg.EnumValues , "SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\90\DTS\Setup", arrValueNames, arrValueTypes
  921.     If Not IsNull(arrValueNames) Then
  922.         strEdition = ""
  923.         strVersion = ""
  924.         intCluster = ""
  925.         strPath = ""
  926.         For i = 0 To UBound(arrValueNames)
  927.             If arrValueNames(i) = "Edition" Then
  928.                 objReg.GetStringValue ,"SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\90\DTS\Setup",arrValueNames(i) ,strEdition
  929.             ElseIf arrValueNames(i) = "Version" Then
  930.                 objReg.GetStringValue ,"SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\90\DTS\Setup",arrValueNames(i) ,strVersion
  931.             ElseIf arrValueNames(i) = "SqlCluster" Then
  932.                 objReg.GetDWORDValue ,"SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\90\DTS\Setup",arrValueNames(i) ,intCluster
  933.             ElseIf arrValueNames(i) = "SQLPath" Then
  934.                 objReg.GetStringValue ,"SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\90\DTS\Setup",arrValueNames(i) ,strPath
  935.             End If
  936.         Next
  937.         If strEdition <> "" And strVersion <> "" Then
  938.             strOutput = strOutput & "Integration;" & strEdition & ";" & strVersion & ";" & intCluster & ";" & strPath & vbCrLf
  939.         End If
  940.         arrValueNames = Array()
  941.         arrValueTypes = Array()
  942.     End If 
  943.  
  944.     'Checking for SQL Integration Services 2008 and 2008R2
  945.     objReg.EnumValues , "SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\100\DTS\Setup", arrValueNames, arrValueTypes
  946.     If Not IsNull(arrValueNames) Then
  947.         strEdition = ""
  948.         strVersion = ""
  949.         intCluster = ""
  950.         strPath = ""
  951.         For i = 0 To UBound(arrValueNames)
  952.             If arrValueNames(i) = "Edition" Then
  953.                 objReg.GetStringValue ,"SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\100\DTS\Setup",arrValueNames(i) ,strEdition
  954.             ElseIf arrValueNames(i) = "Version" Then
  955.                 objReg.GetStringValue ,"SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\100\DTS\Setup",arrValueNames(i) ,strVersion
  956.             ElseIf arrValueNames(i) = "SqlCluster" Then
  957.                 objReg.GetDWORDValue ,"SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\100\DTS\Setup",arrValueNames(i) ,intCluster
  958.             ElseIf arrValueNames(i) = "SQLPath" Then
  959.                 objReg.GetStringValue ,"SOFTWARE" & strWow6432node & "\Microsoft\Microsoft SQL Server\100\DTS\Setup",arrValueNames(i) ,strPath
  960.             End If
  961.         Next
  962.         If strEdition <> "" And strVersion <> "" Then
  963.             strOutput = strOutput & "Integration;" & strEdition & ";" & strVersion & ";" & intCluster & ";" & strPath & vbCrLf
  964.         End If
  965.         arrValueNames = Array()
  966.         arrValueTypes = Array()
  967.     End If 
  968.  
  969.     If strOutput <> "" Then
  970.         SQLInformation = strOutput
  971.     End If
  972.  
  973. End Function
  974.  
  975. 'Events Logs
  976. Function Events104(oWMI)
  977.         On Error Resume Next
  978.     Set colLoggedEvents = oWMI.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventCode = '104'")
  979.     Events104 = "Information;Machinename;Hostname;EventMessage;Source;Location;Date" &  vbCrLf
  980.     For Each objEvent In colLoggedEvents
  981.         'Events = Events & objEvent.ComputerName & ";" & objEvent.TimeWritten & ";" & Replace(Replace(objEvent.Message, vbCr, ""), vbLf, "") & vbCrLf
  982.         'Events104 = Events104 & "EventLog1" & ";" & PwCHostname & ";" & CurrentLocation & ";" & objEvent.ComputerName & ";" & WMIDateStringToDate(objEvent.TimeWritten) &  & vbCrLf
  983.         Events104 = Events104 & "EventLog1" & ";" & objEvent.ComputerName & ";" & PwCHostname & ";" & Replace(Replace(objEvent.Message, vbCr, ""), vbLf, "") & ";" & "Semi-Automated" & ";" & CurrentLocation & ";" & WMIDateStringToDate(objEvent.TimeWritten) & vbCrLf
  984. Next
  985. End Function
  986.  
  987. Function Events11707(oWMI)
  988.         On Error Resume Next
  989.     Set colLoggedEvents = oWMI.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'Application' and EventCode = '11707'")
  990.     Events11707 = "Information;Machinename;Hostname;Product Name;Source;Location;Date" &  vbCrLf
  991.     For Each objEvent In colLoggedEvents
  992.     If InStr(objEvent.Message, "Microsoft") > 0 Then
  993.         'Events = Events & objEvent.ComputerName & ";" & objEvent.TimeWritten & ";" & Replace(Replace(objEvent.Message, vbCr, ""), vbLf, "") & vbCrLf
  994.         Events11707 = Events11707 & "EventLog2" & ";" & objEvent.ComputerName & ";" & PwCHostname & ";" & Replace(Replace(objEvent.Message, vbCr, ""), vbLf, "") & ";"  & "Semi-Automated" & ";" & CurrentLocation & ";" & WMIDateStringToDate(objEvent.TimeWritten) & vbCrLf
  995.     End If
  996. Next
  997. End Function
  998.  
  999.  
  1000. Function Events592(oWMI)
  1001.         On Error Resume Next
  1002.     Set colLoggedEvents = oWMI.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'Security' and EventCode = '592'")
  1003.     Events592 = "Information;Machinename;Hostname;Product Name;Source;Location;Date" &  vbCrLf
  1004.     For Each objEvent In colLoggedEvents
  1005.     If InStr(objEvent.Message, "Microsoft") > 0 Then
  1006.         'Events = Events & objEvent.ComputerName & ";" & objEvent.TimeWritten & ";" & Replace(Replace(objEvent.Message, vbCr, ""), vbLf, "") & vbCrLf
  1007.         Events592 = Events592 & "EventLog3" & ";" & objEvent.ComputerName & ";" & PwCHostname & ";" & Replace(Replace(objEvent.Message, vbCr, ""), vbLf, "") & ";"  & "Semi-Automated" & ";" & CurrentLocation & ";" & WMIDateStringToDate(objEvent.TimeWritten) & vbCrLf
  1008.     End If
  1009. Next
  1010. End Function
  1011.  
  1012.    
  1013. Function Events11724(oWMI)
  1014.     On Error Resume Next
  1015.     Set colLoggedEvents = oWMI.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'Application' and EventCode = '11724'")
  1016.     Events11724 = "Information;Machinename;Hostname;Product Name;Source;Location;Date" &  vbCrLf
  1017.     For Each objEvent In colLoggedEvents
  1018.     If InStr(objEvent.Message, "Microsoft") > 0 Then
  1019.         'Events = Events & objEvent.ComputerName & ";" & objEvent.TimeWritten & ";" & Replace(Replace(objEvent.Message, vbCr, ""), vbLf, "") & vbCrLf
  1020.         Events11724 = Events11724 & "EventLog4" & ";" & objEvent.ComputerName & ";" & PwCHostname & ";" & Replace(Replace(objEvent.Message, vbCr, ""), vbLf, "") & ";"  & "Semi-Automated" & ";" & CurrentLocation & ";" & WMIDateStringToDate(objEvent.TimeWritten) & vbCrLf
  1021.     End If
  1022. Next
  1023. End Function
  1024.  
  1025.  
  1026. 'Function WMIDateStringToDate(dtmDate)
  1027. '   WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
  1028. '   Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) &_
  1029. '   " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
  1030.    
  1031. 'End Function
  1032.  
  1033.  
  1034. Function WMIDateStringToDate(dtmDate)
  1035.         strDate= CDate(Mid(dtmDate, 5, 2) & "/" & _
  1036.     Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) &_
  1037.     " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
  1038.    
  1039.     WMIDateStringToDate = day(strDate) & "-" & month(strDate) & "-" & year(strDate) &_
  1040.         " " & Hour(strDate) & ":"& minute(strDate) & ":" & second(strDate)
  1041.    
  1042. End Function
  1043.  
  1044.  
  1045. 'Function to encrypt the data. The array "key" is essentially the rotating key password!
  1046. Function encrpt(data2encr)
  1047. arrLines = Split(data2encr,vbCrLf)
  1048. tempnew = ""
  1049.  
  1050. 'Key can be of any length! Recommended to keep it at least 6 char long!
  1051. tempkey = "9328362663"
  1052. Dim key()
  1053. For i=1 To Len(tempkey)
  1054.     ReDim Preserve key(i-1)
  1055.     key(i-1)=Mid(tempkey,i,1)  
  1056. Next
  1057.  
  1058.  
  1059. for j=0 to UBound(arrLines)
  1060.     xyz=arrLines(j)
  1061.     keycounter=0
  1062.     currentkey=0
  1063.  
  1064.     for i=1 to len(xyz)
  1065.             c=Asc(mid(xyz,i,1))
  1066.         currentkey=key(keycounter)
  1067.         keycounter=keycounter+1
  1068.         if keycounter>UBound(key) then
  1069.             keycounter=0
  1070.         end if
  1071.         c=c+currentkey
  1072.         tempnew = tempnew & chr(c)
  1073.     next
  1074.     keycounter=0
  1075.     tempnew = tempnew & vbCrLf
  1076. next
  1077. encrpt=tempnew
  1078.  
  1079. End Function
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085. Function macidtostring(pwcmacid)
  1086.     'Example MAC ID    6C:88:14:08:28:DC
  1087.     a=Split(pwcmacid,":")
  1088.     newid=""
  1089.     For Each x In a
  1090.         newid=newid & x
  1091.     Next
  1092.     macidtostring=newid
  1093. End Function
  1094.  
  1095.  
  1096. 'MsgBox Report
  1097. 'MsgBox "Completed ! Thank you for your Patience."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement