Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 788
  • Last Modified:

Comparing two Arrays

Short and sweet, I need to know what computers are in my AD list that aren't in my SCCM list.  Everything is returning true whether it is in the list or not.
' ------ SET INPUT FILE ------
strfile="AD_Computer_Names_2.txt"
set iFSO=createobject("scripting.filesystemobject")
set objTS=iFSO.opentextfile(strfile)
 
strfile2="SCCM_Client_Names_2.txt"
set iFSO2=createobject("scripting.filesystemobject")
set objTS2=iFSO2.opentextfile(strfile)
 
 
' ------ SET OUTPUT FILES ------
OutputFile="AD_SCCM.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile(OutputFile, True)
 
x=0
	Do While objTS.atendofstream<>true
 
		strADComputer=objts.readline
		
		ReDim Preserve arrADComputers(x)
		arrADComputers(x) = UCase(strADComputer)
		x=x+1
 
	Loop
 
y=0
	Do While objTS2.atendofstream<>true
 
		strSCCMComputer=objts2.readline
		
		ReDim Preserve arrSCCMComputers(y)
		arrSCCMComputers(y) = UCase(strSCCMComputer)
		y=y+1
 
	Loop
 
 
 
 
Set objListSCCM = CreateObject("Scripting.Dictionary")
'objListSCCM.CompareMode = vbTextCompare
	For s = 0 To UBound(arrSCCMComputers)
		If objListSCCM.Exists(arrSCCMComputers(s)) Then
		Else
			objListSCCM.add (arrSCCMComputers(s)), (arrSCCMComputers(s))
		End If
	Next
 
 
Set objListAD = CreateObject("Scripting.Dictionary")
'objListAD.CompareMode = vbTextCompare
	For t = 0 To UBound(arrADComputers)
		If objListAD.Exists(arrADComputers(t)) Then
		Else
			objListAD.add (arrADComputers(t)), (arrADComputers(t))
		End If
	Next
 
 
For n = 0 To UBound(arrADComputers)  
	If objListSCCM.Exists(arrADComputers(n)) Then
	wscript.echo arrADComputers(n)
	Else
		Wscript.Echo arrADComputers(n) & " is in AD but not SCCM"  
	End If  
Next  
 
 
 
 
 
wscript.echo "Done"

Open in new window

0
sunnyd24
Asked:
sunnyd24
  • 3
1 Solution
 
dan_nealCommented:
Would you be willing to post the files you are comparing or at list a few lines of each?
0
 
TakedaTCommented:
Line 8 is :

set objTS2=iFSO2.opentextfile(strfile)

Should it be

set objTS2=iFSO2.opentextfile(strfile2)

Just noticed that at first glance.
0
 
TakedaTCommented:
I just tested it.  That appears to be the only thing you missed.  Add that 2 in line 8 and you should be fine.  I cant tell you how many times I have done something similar.
0
 
TakedaTCommented:
I also noticed that you output file is not being used.  Im not sure what exactly you want it to say in there, but you can add this line inbetween lines 64 and 65.

oFile.write arrADComputers(n)&VbCrLf
0
 
sunnyd24Author Commented:
TakedaT you were exactly right.  I tried running that same code past two other people and no one noticed.  I just hadn't gotten around to putting the results to the output file yet because I couldn't get past the compare, but thanks again!  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now