strComputer = "."
Dim arrFolders()
i = 0
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
strFolderName = "C:\Temp"
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objFolder in colSubfolders
strName = objFolder.name
arrNames = Split(strName, "\")
intIndex = Ubound(arrNames)
Redim Preserve arrFolders (i)
arrFolders (i) = arrNames(intIndex)
'Wscript.Echo arrNames(intIndex)
i = i + 1
Next
Const FOR_WRITING = 2
Dim objFso
Dim objOutputFile
Dim strOutputFile
Dim arrFirst
Dim arrSecond
Dim strElementFirst
Dim strElementSecond
Dim blnExistsInSecond
strOutputFile = "C:\temp\Differences.txt"
Set objFso = CreateObject("Scripting.FileSystemObject")
If objFso.FileExists(strOutputFile) Then
Set objOutputFile = objFso.OpenTextFile(strOutputFile,FOR_WRITING)
Else
Set objOutputFile = objFso.CreateTextFile(strOutputFile)
End If
'arrFirst consists of the user directories in the server's user share
arrFirst = arrFolders
'arrSecond consists of user hmdir mappings found in AD for that specific server (currently psuedo entries)
arrSecond = Array("F","G","H","a","B","Z","foLdEr12")
For Each strElementFirst In arrFirst
blnExistsInSecond = False
For Each strElementSecond In arrSecond
'If strElementFirst = strElementSecond Then
If lcase(strElementFirst) = lcase(strElementSecond) Then
blnExistsInSecond = True
Exit For
End If
Next
If Not blnExistsInSecond Then
objOutputFile.WriteLine strElementFirst & " does not exist in the second array"
End If
Next
ASKER
ASKER
strComputer = "."
Dim arrFolders()
i = 0
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
strFolderName = "\\YourServerName\Users"
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objFolder in colSubfolders
strName = objFolder.name
arrNames = Split(strName, "\")
intIndex = Ubound(arrNames)
Redim Preserve arrFolders (i)
arrFolders (i) = arrNames(intIndex)
'Wscript.Echo arrNames(intIndex)
i = i + 1
Next
ASKER
ASKER
ASKER
Next
objOutput.Close
Wscript.Echo "strFolderBase count on drive: " & objFolderUsers.count
wscript.Echo "strUserBase count in AD: " & objOUUsers.count
MsgBox "Done. Please see " & strOutputFile
ASKER
ASKER
ASKER
VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.
TRUSTED BY
Set the top three parameters and you should be good to go.
Regards,
Rob.
Open in new window