Script to make a file inventory on a file server

Hello

To accomplish a company audit, I have to create a script that scan our windows 2003 standard file server and create a report with a list of certain files type like mp3, video and so on. In the list have to be present path, file name, and file owner. I already searched on Google, but I don't find anything usable.

Someone could help me ?

 

Thanks

Raven

December 2nd, 2010 7:11pm

something like this will do

gci *.mp3, *.avi -recurse | foreach { write-host "$($_.fullname) - $($_.getaccesscontrol().owner)"}

Free Windows Admin Tool Kit Click here and download it now
December 2nd, 2010 7:31pm

Something like this?

$dirpath = <directory to search>

$ext = "*.mp3","*.avi" #add whatever extension type you want to search for


gci $dirpath -recurse -include  $ext |? {-not $_.psiscontainer} | select name,fullname,@{name="Owner";expression={$_.getaccesscontrol().owner}} | export-csv c:\somedir\filereport.csv -notype

December 2nd, 2010 7:41pm

I like that, except I'd change out FullName for Directory and maybe add the size, which is usually helpful in a storage audit. 

$searchdir = "d:\ShareRoot","e:\ShareRoot"
$ext = "*.mp3","*.wma" ## etc etc

$searchdir | % { gci $_ -recurse -include $ext | select Name,Directory,@{Name="Size in MB";expression={$_.Length / 1mb}},@{Name="Owner";expression={$_.getaccesscontrol().Owner}}} | Export-Csv C:\DirResult.csv -notype

  • Marked as answer by Raven1970 Friday, December 03, 2010 2:56 PM
Free Windows Admin Tool Kit Click here and download it now
December 2nd, 2010 8:10pm

Woooow great !!!!! Many Thanks :-)
December 3rd, 2010 6:00pm

I like that, except I'd change out FullName for Directory and maybe add the size, which is usually helpful in a storage audit. 

$searchdir = "d:\ShareRoot","e:\ShareRoot"
$ext = "*.mp3","*.wma" ## etc etc

$searchdir | % { gci $_ -recurse -include $ext | select Name,Directory,@{Name="Size in MB";expression={$_.Length / 1mb}},@{Name="Owner";expression={$_.getaccesscontrol().Owner}}} | Export-Csv C:\DirResult.csv -notype


Thanks, this is a very useful script. How could the output be amended to also include file creation and modification date?
Free Windows Admin Tool Kit Click here and download it now
June 21st, 2013 10:53am

Dear all,

Is there anyway I can update this script so that it also outputs the last accessed date/time of the files as well?

January 12th, 2014 5:58pm

Yes, add the LastAccessTime property to the select command.

If you have additional questions, you should start your own thread.

Free Windows Admin Tool Kit Click here and download it now
January 12th, 2014 8:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics