How to determine file ownership for all files and subfolders

Discussion in 'Scripting' started by Joe, Mar 22, 2005.

  1. Joe

    Joe Guest

    I need to determine what files are owned by what users in an entire directory
    structure \\servername\sharename\*.*. I'm not sure about how to accomplish
    this. Any help will be greatly appreciated.

    Thank you,

    Joe
     
    Joe, Mar 22, 2005
    #1
    1. Advertisements


  2. See tip 7204 in the 'Tips & Tricks' at http://www.jsiinc.com

    WhoOwnsit \\ServerName\ShareName

    @echo off
    if {%1}=={} @echo Syntax: call WhoOwnsIt Object&goto :EOF
    setlocal ENABLEDELAYEDEXPANSION
    set object=%1
    set object="%object:"=%"
    call WhoOwns %object% who
    @echo %object%,"%who%"
    for /f "Tokens=*" %%a in ('dir %object% /b /s') do (
    call WhoOwns "%%a" who
    @echo "%%a","!who!"
    )
    endlocal

    Jerold Schulman
    Windows Server MVP
    JSI, Inc.
    http://www.jsiinc.com
     
    Jerold Schulman, Mar 23, 2005
    #2
    1. Advertisements

  3. Joe

    Joe Guest

    Jerold,

    Thank you for your reply. I am sorry but I wasn't very specific on what I
    wanted. I would like to have a script that will generate a report for me
    that will list the paths and filenames as well as the owner's account for all
    files in the \\servername\sharename folder and its subfolders.

    It would also be helpful if I could specify for which users to run the report.

    Thank you,

    Joe
     
    Joe, Mar 23, 2005
    #3
  4. The script I gave you, which is now available at tip 9187 in the 'Tips & Tricks' at http://www.jsiinc.com,
    "will list the paths and filenames as well as the owner's account for all files in the \\servername\sharename folder and its subfolders."

    WhoOwnsIt \\servername\sharename

    Output looks like this sample:
    "\\ServerName\ShareName","JSIINC\Jerry"
    "\\ServerName\ShareName\FAX","JSIINC\Jerry"
    "\\ServerName\ShareName\JSI","BUILTIN\Administrators"
    "\\ServerName\ShareName\KBArticle.html","JSIINC\Jerry"

    If you wanted to restruct it to 1 user, like JSIINC\Jerry, then type

    for /F "Tokens=1* Delims=," %a in ('WhoOwnsIt \\ServerName\ShareName^|FINDSTR /I /L /E /C:"""JSIINC\Jerry"""') do @echo %a,%b



    Jerold Schulman
    Windows Server MVP
    JSI, Inc.
    http://www.jsiinc.com
     
    Jerold Schulman, Mar 24, 2005
    #4
  5. Joe

    Joe Guest

    Jerold,

    Thank you for your replies. I really appreciate it and I like your website.
    It rocks!

    Joe
     
    Joe, Mar 24, 2005
    #5
  6. Joe

    Joe Guest

    Jerold,

    When I try to run that I get the following message: The process tried to
    write to a nonexistent pipe. Maybe I have misunderstood. I have whoownsit
    and whoowns in the same folder. From a command line I typed: for /F
    "Tokens=1* Delims=," %a in ('WhoOwnsIt \ServerName\ShareName^|FINDSTR /I /L
    /E /C:"""DOMAINNAME\USERNAME"""') do @echo %a,%b

    What am I missing?

    Thanks,

    Joe
     
    Joe, Mar 24, 2005
    #6
  7. I hope you don't have too many folders, files or users! what are you
    going to do with all this?
     
    Gerry Hickman, Mar 24, 2005
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.