Hello,
I have a script that came together from joint efforts of people and using some code I found on the web to Frankenstein the script. After months of using it, it no longer runs due to an error. It looks like an obvious error but I am not sure how to go about verifying or fixing it. I am not a strong or even intermediate VBS programmer. Any help would be greatly appreciated!
Error:
Line: 86
Char: 1
Error: Table Does Not Exist
Code: 80040E37
Source: Provider
Code:
Option Explicit
Dim adoCommand, adoConnection, strBase, strFilter, strFilter2, strAttributes
Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strDN,
strBaseOU
Dim strExcelpath, strExcelpath2, objExcel, objSheet, intRow, intCol, objUser
Dim arrbytSIDs, objGroupList, j, arrstrGroupSIDs(), objGroup
Dim strGroupName
Dim oShell, oEnv, oFS, strDirectory, strIncrement, numIncrement
'Create the folder to place the reports.
Set oShell = CreateObject("wscript.Shell")
set oFS = CreateObject("scripting.FileSystemObject")
Set oEnv = oShell.Environment("Process")
strDirectory = oEnv("USERPROFILE") & "\Desktop\Audit Reports"
if not oFS.FolderExists(strDirectory) then oFS.CreateFolder(strDirectory &
strIncrement)
'--- this is new
strDirectory=strDirectory & "\" & "XX " & Month(Now) & "-" & Day(Now) &
"-" & Year(Now)
strIncrement = ""
numIncrement = 0
Do While True
if not oFS.FolderExists(strDirectory & strIncrement) then
oFS.CreateFolder(strDirectory & strIncrement)
strDirectory=strDirectory & strIncrement
Exit Do
Else
numIncrement=numIncrement+1
strIncrement="_" & CStr(numIncrement)
End If
Loop
' Spreadsheet file name to be created.
strExcelPath = strDirectory & "\XX-Active.xls"
strExcelPath2 = strDirectory & "\XX-Disabled.xls"
' Bind to Excel.
Set objExcel = CreateObject("Excel.Application")
' Create new workbook.
objExcel.Workbooks.Add
' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Name = "Domain Users"
' Write column headings.
objSheet.Cells(1, 1).Value = "sAMAccountName"
objSheet.Cells(1, 2).value = "Distinguished Name"
objSheet.Cells(1, 3).Value = "Group Memberships"
' Dictionary object to keep track of group SID values.
Set objGroupList = CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Edit the next line to reflect your OU
strBaseOU ="OU=XX,OU=Accounts"
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase ="<LDAP://" & strBaseOU & "," & strDNSDomain & ">"
strFilter = "(&(objectCategory=person)(objectClass=user)" _
& "(!userAccountControl:1.2.840.113556.1.4.803:=2))"
strFilter2 = "(&(objectCategory=person)(objectClass=user)" _
& "(userAccountControl:1.2.840.113556.1.4.803:=2))"
' Comma delimited list of attribute values to retrieve.
' Cannot retrieve tokenGroups with ADO.
strAttributes = "sAMAccountName,distinguishedName"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute ' Line 76
' Enumerate the resulting recordset.
intRow = 2
Do Until adoRecordset.EOF
' Retrieve values and display.
strName = adoRecordset.Fields("sAMAccountName").Value
objSheet.Cells(intRow, 1).Value = strName
strDN = adoRecordset.Fields("distinguishedName").value
strDN = Replace(strDN, "/", "\/")
objSheet.Cells(intRow, 2).Value = Mid(Split(strDN,",")(0),4)
' Bind to the user object.
Set objUser = GetObject("LDAP://" & strDN)
' Retrieve tokenGroups attribute.
objUser.GetInfoEx Array("tokenGroups"), 0
arrbytSIDs = objUser.Get("tokenGroups")
If (UBound(arrbytSIDs) = -1) Then
' No group SID values, do nothing.
ElseIf (TypeName(arrbytSIDs) = "Byte()") Then
' One group SID.
ReDim arrstrGroupSIDs(0)
arrstrGroupSIDs(0) = OctetToHexStr(arrbytSIDs)
' Check if this group encountered before.
If (objGroupList.Exists(arrstrGroupSIDs(0)) = False) Then
' Save group SID and name in dictionary object.
Set objGroup = GetObject("LDAP://<SID=" & arrstrGroupSIDs(0) &
">")
strGroupName = objGroup.distinguishedName
objGroupList.Add arrstrGroupSIDs, strGroupName
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
Else
' Retrieve group name from dictionary object.
strGroupName = objGroupList(arrstrGroupSIDs(0))
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
End If
Else
' More than one SID value in the array.
intCol = 3
ReDim arrstrGroupSIDs(UBound(arrbytSIDs))
For j = 0 To UBound(arrbytSIDs)
arrstrGroupSIDs(j) = OctetToHexStr(arrbytSIDs(j))
' Check if this group encountered before.
If (objGroupList.Exists(arrstrGroupSIDs(j)) = False) Then
' Save group SID and name in dictionary object.
Set objGroup = GetObject("LDAP://<SID=" &
arrstrGroupSIDs(j) & ">")
strGroupName = objGroup.distinguishedName
objGroupList.Add arrstrGroupSIDs(j), strGroupName
'objSheet.Cells(intRow, intCol).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
Else
' Retrieve group name from dictionary object.
strGroupName = objGroupList(arrstrGroupSIDs(j))
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
End If
Next
End If
' Move to the next record in the recordset.
intRow = intRow + 1
adoRecordset.MoveNext
Loop
' Save spreadsheet and close the workbook.
objExcel.ActiveWorkbook.SaveAs strExcelPath
objExcel.ActiveWorkbook.Close
' Quit Excel and clean up.
objExcel.Application.Quit
objExcel.Application.Quit
'adoRecordset.Close
'adoConnection.Close
' Bind to Excel.
Set objExcel = CreateObject("Excel.Application")
' Create new workbook.
objExcel.Workbooks.Add
' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Name = "Domain Users"
' Write column headings.
objSheet.Cells(1, 1).Value = "sAMAccountName"
objSheet.Cells(1, 2).value = "Distinguished Name"
objSheet.Cells(1, 3).Value = "Group Memberships"
' Dictionary object to keep track of group SID values.
Set objGroupList = CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Edit the next line to reflect your OU
strBaseOU ="OU=DE,OU=Accounts"
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase ="<LDAP://" & strBaseOU & "," & strDNSDomain & ">"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter2 & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute
' Enumerate the resulting recordset for disabled accounts.
intRow = 2
Do Until adoRecordset.EOF
' Retrieve values and display.
strName = adoRecordset.Fields("sAMAccountName").Value
objSheet.Cells(intRow, 1).Value = strName
strDN = adoRecordset.Fields("distinguishedName").value
strDN = Replace(strDN, "/", "\/")
objSheet.Cells(intRow, 2).Value = Mid(Split(strDN,",")(0),4)
' Bind to the user object.
Set objUser = GetObject("LDAP://" & strDN)
' Retrieve tokenGroups attribute.
objUser.GetInfoEx Array("tokenGroups"), 0
arrbytSIDs = objUser.Get("tokenGroups")
If (UBound(arrbytSIDs) = -1) Then
' No group SID values, do nothing.
ElseIf (TypeName(arrbytSIDs) = "Byte()") Then
' One group SID.
ReDim arrstrGroupSIDs(0)
arrstrGroupSIDs(0) = OctetToHexStr(arrbytSIDs)
' Check if this group encountered before.
If (objGroupList.Exists(arrstrGroupSIDs(0)) = False) Then
' Save group SID and name in dictionary object.
Set objGroup = GetObject("LDAP://<SID=" & arrstrGroupSIDs(0) &
">")
strGroupName = objGroup.distinguishedName
objGroupList.Add arrstrGroupSIDs, strGroupName
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
Else
' Retrieve group name from dictionary object.
strGroupName = objGroupList(arrstrGroupSIDs(0))
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
End If
Else
' More than one SID value in the array.
intCol = 3
ReDim arrstrGroupSIDs(UBound(arrbytSIDs))
For j = 0 To UBound(arrbytSIDs)
arrstrGroupSIDs(j) = OctetToHexStr(arrbytSIDs(j))
' Check if this group encountered before.
If (objGroupList.Exists(arrstrGroupSIDs(j)) = False) Then
' Save group SID and name in dictionary object.
Set objGroup = GetObject("LDAP://<SID=" &
arrstrGroupSIDs(j) & ">")
strGroupName = objGroup.distinguishedName
objGroupList.Add arrstrGroupSIDs(j), strGroupName
'objSheet.Cells(intRow, intCol).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
Else
' Retrieve group name from dictionary object.
strGroupName = objGroupList(arrstrGroupSIDs(j))
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
End If
Next
End If
' Move to the next record in the recordset.
intRow = intRow + 1
adoRecordset.MoveNext
Loop
' Save spreadsheet and close the workbook.
objExcel.ActiveWorkbook.SaveAs strExcelPath2
objExcel.ActiveWorkbook.Close
' Quit Excel and clean up.
objExcel.Application.Quit
objExcel.Application.Quit
adoRecordset.Close
adoConnection.Close
Function OctetToHexStr(ByVal arrbytOctet)
' Function to convert OctetString (byte array) to Hex string.
Dim k
OctetToHexStr = ""
For k = 1 To Lenb(arrbytOctet)
OctetToHexStr = OctetToHexStr _
& Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
Next
End Function
Wscript.Echo "Report Generated
I have a script that came together from joint efforts of people and using some code I found on the web to Frankenstein the script. After months of using it, it no longer runs due to an error. It looks like an obvious error but I am not sure how to go about verifying or fixing it. I am not a strong or even intermediate VBS programmer. Any help would be greatly appreciated!
Error:
Line: 86
Char: 1
Error: Table Does Not Exist
Code: 80040E37
Source: Provider
Code:
Option Explicit
Dim adoCommand, adoConnection, strBase, strFilter, strFilter2, strAttributes
Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strDN,
strBaseOU
Dim strExcelpath, strExcelpath2, objExcel, objSheet, intRow, intCol, objUser
Dim arrbytSIDs, objGroupList, j, arrstrGroupSIDs(), objGroup
Dim strGroupName
Dim oShell, oEnv, oFS, strDirectory, strIncrement, numIncrement
'Create the folder to place the reports.
Set oShell = CreateObject("wscript.Shell")
set oFS = CreateObject("scripting.FileSystemObject")
Set oEnv = oShell.Environment("Process")
strDirectory = oEnv("USERPROFILE") & "\Desktop\Audit Reports"
if not oFS.FolderExists(strDirectory) then oFS.CreateFolder(strDirectory &
strIncrement)
'--- this is new
strDirectory=strDirectory & "\" & "XX " & Month(Now) & "-" & Day(Now) &
"-" & Year(Now)
strIncrement = ""
numIncrement = 0
Do While True
if not oFS.FolderExists(strDirectory & strIncrement) then
oFS.CreateFolder(strDirectory & strIncrement)
strDirectory=strDirectory & strIncrement
Exit Do
Else
numIncrement=numIncrement+1
strIncrement="_" & CStr(numIncrement)
End If
Loop
' Spreadsheet file name to be created.
strExcelPath = strDirectory & "\XX-Active.xls"
strExcelPath2 = strDirectory & "\XX-Disabled.xls"
' Bind to Excel.
Set objExcel = CreateObject("Excel.Application")
' Create new workbook.
objExcel.Workbooks.Add
' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Name = "Domain Users"
' Write column headings.
objSheet.Cells(1, 1).Value = "sAMAccountName"
objSheet.Cells(1, 2).value = "Distinguished Name"
objSheet.Cells(1, 3).Value = "Group Memberships"
' Dictionary object to keep track of group SID values.
Set objGroupList = CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Edit the next line to reflect your OU
strBaseOU ="OU=XX,OU=Accounts"
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase ="<LDAP://" & strBaseOU & "," & strDNSDomain & ">"
strFilter = "(&(objectCategory=person)(objectClass=user)" _
& "(!userAccountControl:1.2.840.113556.1.4.803:=2))"
strFilter2 = "(&(objectCategory=person)(objectClass=user)" _
& "(userAccountControl:1.2.840.113556.1.4.803:=2))"
' Comma delimited list of attribute values to retrieve.
' Cannot retrieve tokenGroups with ADO.
strAttributes = "sAMAccountName,distinguishedName"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute ' Line 76
' Enumerate the resulting recordset.
intRow = 2
Do Until adoRecordset.EOF
' Retrieve values and display.
strName = adoRecordset.Fields("sAMAccountName").Value
objSheet.Cells(intRow, 1).Value = strName
strDN = adoRecordset.Fields("distinguishedName").value
strDN = Replace(strDN, "/", "\/")
objSheet.Cells(intRow, 2).Value = Mid(Split(strDN,",")(0),4)
' Bind to the user object.
Set objUser = GetObject("LDAP://" & strDN)
' Retrieve tokenGroups attribute.
objUser.GetInfoEx Array("tokenGroups"), 0
arrbytSIDs = objUser.Get("tokenGroups")
If (UBound(arrbytSIDs) = -1) Then
' No group SID values, do nothing.
ElseIf (TypeName(arrbytSIDs) = "Byte()") Then
' One group SID.
ReDim arrstrGroupSIDs(0)
arrstrGroupSIDs(0) = OctetToHexStr(arrbytSIDs)
' Check if this group encountered before.
If (objGroupList.Exists(arrstrGroupSIDs(0)) = False) Then
' Save group SID and name in dictionary object.
Set objGroup = GetObject("LDAP://<SID=" & arrstrGroupSIDs(0) &
">")
strGroupName = objGroup.distinguishedName
objGroupList.Add arrstrGroupSIDs, strGroupName
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
Else
' Retrieve group name from dictionary object.
strGroupName = objGroupList(arrstrGroupSIDs(0))
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
End If
Else
' More than one SID value in the array.
intCol = 3
ReDim arrstrGroupSIDs(UBound(arrbytSIDs))
For j = 0 To UBound(arrbytSIDs)
arrstrGroupSIDs(j) = OctetToHexStr(arrbytSIDs(j))
' Check if this group encountered before.
If (objGroupList.Exists(arrstrGroupSIDs(j)) = False) Then
' Save group SID and name in dictionary object.
Set objGroup = GetObject("LDAP://<SID=" &
arrstrGroupSIDs(j) & ">")
strGroupName = objGroup.distinguishedName
objGroupList.Add arrstrGroupSIDs(j), strGroupName
'objSheet.Cells(intRow, intCol).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
Else
' Retrieve group name from dictionary object.
strGroupName = objGroupList(arrstrGroupSIDs(j))
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
End If
Next
End If
' Move to the next record in the recordset.
intRow = intRow + 1
adoRecordset.MoveNext
Loop
' Save spreadsheet and close the workbook.
objExcel.ActiveWorkbook.SaveAs strExcelPath
objExcel.ActiveWorkbook.Close
' Quit Excel and clean up.
objExcel.Application.Quit
objExcel.Application.Quit
'adoRecordset.Close
'adoConnection.Close
' Bind to Excel.
Set objExcel = CreateObject("Excel.Application")
' Create new workbook.
objExcel.Workbooks.Add
' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Name = "Domain Users"
' Write column headings.
objSheet.Cells(1, 1).Value = "sAMAccountName"
objSheet.Cells(1, 2).value = "Distinguished Name"
objSheet.Cells(1, 3).Value = "Group Memberships"
' Dictionary object to keep track of group SID values.
Set objGroupList = CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Edit the next line to reflect your OU
strBaseOU ="OU=DE,OU=Accounts"
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase ="<LDAP://" & strBaseOU & "," & strDNSDomain & ">"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter2 & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute
' Enumerate the resulting recordset for disabled accounts.
intRow = 2
Do Until adoRecordset.EOF
' Retrieve values and display.
strName = adoRecordset.Fields("sAMAccountName").Value
objSheet.Cells(intRow, 1).Value = strName
strDN = adoRecordset.Fields("distinguishedName").value
strDN = Replace(strDN, "/", "\/")
objSheet.Cells(intRow, 2).Value = Mid(Split(strDN,",")(0),4)
' Bind to the user object.
Set objUser = GetObject("LDAP://" & strDN)
' Retrieve tokenGroups attribute.
objUser.GetInfoEx Array("tokenGroups"), 0
arrbytSIDs = objUser.Get("tokenGroups")
If (UBound(arrbytSIDs) = -1) Then
' No group SID values, do nothing.
ElseIf (TypeName(arrbytSIDs) = "Byte()") Then
' One group SID.
ReDim arrstrGroupSIDs(0)
arrstrGroupSIDs(0) = OctetToHexStr(arrbytSIDs)
' Check if this group encountered before.
If (objGroupList.Exists(arrstrGroupSIDs(0)) = False) Then
' Save group SID and name in dictionary object.
Set objGroup = GetObject("LDAP://<SID=" & arrstrGroupSIDs(0) &
">")
strGroupName = objGroup.distinguishedName
objGroupList.Add arrstrGroupSIDs, strGroupName
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
Else
' Retrieve group name from dictionary object.
strGroupName = objGroupList(arrstrGroupSIDs(0))
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
End If
Else
' More than one SID value in the array.
intCol = 3
ReDim arrstrGroupSIDs(UBound(arrbytSIDs))
For j = 0 To UBound(arrbytSIDs)
arrstrGroupSIDs(j) = OctetToHexStr(arrbytSIDs(j))
' Check if this group encountered before.
If (objGroupList.Exists(arrstrGroupSIDs(j)) = False) Then
' Save group SID and name in dictionary object.
Set objGroup = GetObject("LDAP://<SID=" &
arrstrGroupSIDs(j) & ">")
strGroupName = objGroup.distinguishedName
objGroupList.Add arrstrGroupSIDs(j), strGroupName
'objSheet.Cells(intRow, intCol).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
Else
' Retrieve group name from dictionary object.
strGroupName = objGroupList(arrstrGroupSIDs(j))
'objSheet.Cells(intRow, 3).Value = strGroupName
objSheet.Cells(intRow, 3).Value =
Mid(Split(strGroupName,",")(0),4) & Chr(10) &
objSheet.Cells(intRow, 3).Value
End If
Next
End If
' Move to the next record in the recordset.
intRow = intRow + 1
adoRecordset.MoveNext
Loop
' Save spreadsheet and close the workbook.
objExcel.ActiveWorkbook.SaveAs strExcelPath2
objExcel.ActiveWorkbook.Close
' Quit Excel and clean up.
objExcel.Application.Quit
objExcel.Application.Quit
adoRecordset.Close
adoConnection.Close
Function OctetToHexStr(ByVal arrbytOctet)
' Function to convert OctetString (byte array) to Hex string.
Dim k
OctetToHexStr = ""
For k = 1 To Lenb(arrbytOctet)
OctetToHexStr = OctetToHexStr _
& Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
Next
End Function
Wscript.Echo "Report Generated