I wrote this short VBS script today to help out a client; basically, you can run this on an Active Directory domain as a login script to see if your users’ offline shares are correctly configured. In this case, each user is supposed to have a ‘U:’ drive that syncs with a file server whenever they’re on campus, and is available whenever they’re on the road. Sometimes, though, the configuration isn’t set for one reason or another… Hence the script.
‘ u_sync_check: VBscript that grabs the information on offline files and saves it for later auditing.
‘ Written by Rick El-Darwish, 14.05.2013. Inspired by these sites: http://bit.ly/13YTyur and http://bit.ly/17q8Dcx
‘ Grab the name of the computer executing this script:
Set wshShell = WScript.CreateObject( “WScript.Shell” )
strComputerName = wshShell.ExpandEnvironmentStrings( “%COMPUTERNAME%” )
‘ Compose the path of the file under which this information will be stored. TODO: replace the UNC below with a valid path!
outFile=”\myservermyshare” & strComputerName & “.txt”
‘ Create the actual file.
Set objFile = objFSO.CreateTextFile(outFile,True)
‘ Create the WMI object and grab the list of all synched directories.
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\” & strComputer & “rootCIMV2”)
Set colItems = objWMIService.ExecQuery(“SELECT * FROM Win32_OfflineFilesItem WHERE ItemType=2”,,48)
‘ For each synched directory, write an entry in the file
For Each objItem In colItems
objFile.Write “ItemPath : ” & objItem.ItemPath
‘ Close the file