>Option Explicit > >Dim oArgs, oRootFolder, oFSO, oFolder, nSize, nDays > >Set oArgs = WScript.Arguments > >if oArgs.Count = 0 then > WScript.Echo "Folder name required" >end if > >Set oFSO = CreateObject("Scripting.FileSystemObject") >on error resume next >Set oRootFolder = oFSO.GetFolder(oArgs(0)) >On Error Goto 0 > >if oArgs.Count = 2 then > nSize = clng(oArgs(1)) >else > nSize = 10000 >end if > >if oArgs.Count = 3 then > nDays = cInt(oArgs(2)) >else > nDays = 1 >end if > >if IsObject(oRootFolder) then > CheckFiles oRootFolder, nSize, nDays >else > WScript.Echo "Folder " & oArgs(0) & " not found" >end if > > >Sub CheckFiles(oFolder, nSize, nDays) > >Dim oFile > >for each oFile in oFolder.Files > if oFile.Size >= nSize and DateDiff("d", oFile.DateCreated, Now) <= nDays then > WScript.Echo oFile.Path & " " & oFile.Size & " " & oFile.DateCreated & " " & DateDiff("d", oFile.DateCreated, Now) & " Owners: " & getListOfOwners(oFile.Path) > end if >next >for each oFolder in oFolder.SubFolders > CheckFiles oFolder, nSize, nDays >next >end sub > > >Function getListOfOwners(cFile) >dim oWMI, oAssociators, cList, oInfo >Set oWMI = GetObject("winmgmts:") > >On Error Resume Next > >Set oAssociators = oWMI.ExecQuery("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & cFile & "'} WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner") >On Error Goto 0 > >cList = "" >if IsObject(oAssociators) then > For Each oInfo in oAssociators > cList = cList + oInfo.AccountName + "," > Next >end if > >If len(cList)= 0 Then > getListOfOwners = "Unable to retrieve ownership" >else > getListOfOwners = Left(cList, len(cList) - 1) >End If >End Function >>