JSI Tip 9990. How can I locate all the file system objects owned by a security principal?

Using the corrected version of SubInAcl, I have scripted Owners.bat to report all the file system objects owned by the security principal that you specify.

The syntax for using Owners.bat is:

Owners Owner \\computer1\share1 \[\\computer2\SHare2 ... \\computerN\SHareN\]


Owner               is the security principal, like "DomainName\UserName", "builtin\UserOrGroup, etc...

\\computer1\share1  Where to begin the search. Both UNC and local folder names are supported.

\\computerX\SHareX  Optional additional shares and/or folders to search.
The output, in CSV format, is written to an Owners_<Random Number>.txt file in the current directory.

Owners.bat contains:

@echo off
if \{%2\}

\{\} @echo Syntax: Owners Owner \\computer1\share1 \[\\computer2\SHare2 ... \\computerN\SHareN\]&goto :EOF setlocal ENABLEDELAYEDEXPANSION set report="Owners_%RANDOM%.txt" set work="%TEMP%\Owners_%RANDOM%.TMP" set owner=%1 shift set owner=%owner:"=% :loop if \{%1\}

\{\} goto finish set share=%1 shift set share=%share:"=% if not exist "%share%" goto err SubInAcl /outputlog=%work% /noverbose /nostatistic /file "%share%" for /f "tokens=1* Delims

" %%x in ('type %work%^|find "/owner"^|Find /i "%owner%"') do ( @echo "%share%","%%y">>%report% ) for /f "Tokens=*" %%f in ('dir "%share%" /b /s /a') do ( SubInAcl /outputlog=%work% /noverbose /nostatistic /file "%%f" for /f "tokens=1* Delims

" %%x in ('type %work%^|find "/owner"^|Find /i "%owner%"') do ( @echo "%%f","%%y">>%report% ) ) goto loop :err @echo "%share%","NOT FOUND">>%report% goto loop :finish del /q %work% endlocal

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.