Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scripting help... get list of files with owner and date
Message
Information générale
Forum:
Windows
Catégorie:
Administration & Sécurité
Divers
Thread ID:
01108105
Message ID:
01109016
Vues:
27
>I do not know how to program, I just steal some code from here and some code from there, google is your friend, well, at least it is mine.

Sure...


Here's my code, it gives me the owner of the file and the full path and the size of it. Now, if I could get all in one line and comma separated I would be even happier! *grin*

I stile the ownershiop code, as you suggested I do, from: http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1007.mspx
'Option Explicit

'Dim oArgs, oRootFolder, oFSO, oFolder, nSize

Set oArgs = WScript.Arguments

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

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 = 1048576
end if

if IsObject(oRootFolder) then
	CheckFiles oRootFolder, nSize
else
	WScript.Echo "Folder " & oArgs(0) & " not found"
end if


Sub CheckFiles(oFolder, nSize)

Dim oFile

for each oFile in oFolder.Files
	if oFile.Size >= nSize and DateDiff("d", oFile.DateCreated, Now) <= 1  then
		strFile = oFile.Path
			Set colItems = objWMIService.ExecQuery _
			    ("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile & "'}" & " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")

			For Each objItem in colItems
				'Wscript.Echo objItem.ReferencedDomainName 
				Wscript.Echo objItem.AccountName
			Next		
		WScript.Echo oFile.Path & "," & oFile.Size & "," & oFile.DateCreated & "," & DateDiff("h", oFile.DateCreated, Now)
	end if
next
'Skip the next for-next if you do not want to recurse subfolders
for each oFolder in oFolder.SubFolders
	CheckFiles oFolder, nSize
next
end sub
Alex
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform