My current project has recently required that i be able to report on the Network UNC shares consumed by each Active Directory OU. Not easy to accomplish when your domain is in excess of 110 OU’s and 10k+ users.
This will be a two part example : (update to complete second part)
1. What i have to start with is a list of network login scripts for all users in a given AD OU. How i got this data is irrelevant for now (still compiling java).
2. Here : https://bomber.dyndns.org/dropbox/Public/Uploads/GetUNC.zip is a little .jar file that will ask for a NetBIOS Domain Name (NONE canonical), Server (forced target for specific/local Domain Controller for the lookups) and login script. It than iterates through the script and extracts all NET USE statements with PERSISTENT on and dumps into a lsUNCshares.csv.
You can run it as a batch by putting
for /F “eol=; tokens=1 delims=,” %%A in (lscriptlist.txt) do @”java.exe” -jar GetScriptUNCs.jar %%A > %%AResults.csv
in a run.cmd batch file in the same directory as the .jar. Edit a lscriptlilst.txt with the output of all login scripts you want to check and run it.
Bang. A list of all UNC Shares for all login scripts in a file.
Shoutout goes to Carl Billings for assistance with this code segment.