[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

file share and directory report

Posted on 2014-04-08
10
Medium Priority
?
466 Views
Last Modified: 2014-05-28
is there any easy way in powershell to produce a report around a file servers structure?

i.e. essentially I want it to report all shares and the root level directories into one report. I dont want the report to go any deeper that the top level root folders per share i.e.\\server\share\folder1 \\server\share\folder2? I would be running the script with domain admin permissions so it should have permissions to enumerate everything. Ideally written to CSV would be excellent?
0
Comment
Question by:pma111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 10

Expert Comment

by:Scott Thomson
ID: 39985313
What sort of data are you hoping to extract from this report my friend??

You want just the top folder name and you want to know
- How many folders and files are in the subdirectories?
- What size the top level folder and all subdirectories equal?

So I guess what I am asking is
Lets say you have 10 folders in the top directory
Finance
Administration
IT
Management
ETC

Do you want a detailed report of files and folders and size etc under each of the main directories so you can show a manager how much space finance is wasting (it's always finance ) ^_^ or something similar..?
0
 
LVL 3

Author Comment

by:pma111
ID: 39985360
Numbers would be great. I am not to bothered about size of each directory but theres no harm including that directory and it could be useful.

I.e. say for example my server has 5 shares, and in those 10 root (top) level directories, I'd expect the report to list 50 rows of data. However, it would be great to see how many sub dirs are in each root level directory, but this information isnt essential. So just UNC paths would be sufficient in the end report.

Ideally the end report would be something along the lines of

\\server1\share1\dir1
\\server1\share1\dir2
\\server1\share2\dir1
\\server2\share1\dir1

etc, ideally written to CSV.
0
 
LVL 10

Expert Comment

by:Scott Thomson
ID: 39985372
So just to confirm

UNC paths of each of the top level directories?
All thrown into a CSV?
0
Cyber Threats to Small Businesses (Part 1)

This past May, Webroot surveyed more than 600 IT decision-makers at medium-sized companies to see how these small businesses perceived new threats facing their organizations.  Read what Webroot CISO, Gary Hayslip, has to say about the survey in part 1 of this 2-part blog series.

 
LVL 3

Author Comment

by:pma111
ID: 39985419
Yes please
0
 
LVL 3

Author Comment

by:pma111
ID: 39993779
Is this not doable?
0
 
LVL 44

Accepted Solution

by:
Davis McCarn earned 668 total points
ID: 40090935
I'm an old fashioned kind of guy and use the CMD prompt regularly so chew on this one:\

net view \\%computername% >> g:\%computername%-shares.txt

If you substitute g: with a path to a share and push it to however many servers or PC's you want, you'll wind up with a listing of all of the shares.  If you want them all in one file, create a blank shares.txt file and use this:

net view \\%computername% > \\<servername>\<sharename>\shares.txt
0
 
LVL 41

Assisted Solution

by:footech
footech earned 668 total points
ID: 40090975
Yes, it's possible.
An easy way?  That's a matter of opinion, and all depends on what information you need/want, how you want it formatted, and in what scenarios you want it to work.

With that said, I generally try to discourage people from asking for complete scripts here that involve anything more than few lines.  It's much better to ask questions on particular points that you get stuck on or need explanation.  Contribute whatever code you have, whether written by yourself or found elsewhere, and show where you're stuck.  The MS Technet Script Repository is a great place to start.  You can search for results by type of script.
Technet Script Repository

Something like the following would pretty much give the info you want for the local machine.
Get-WmiObject win32_share  -filter "type = 0" | % { Get-ChildItem $_.path | ? {$_.PsisContainer} } | select fullname

Open in new window

But as I mentioned, formatting the data (e.g. to show UNC paths), working against remote computers, and choosing other data to display all adds to the code.
0
 
LVL 25

Assisted Solution

by:Lionel MM
Lionel MM earned 664 total points
ID: 40091900
OK I just tested a batch file--works but is not all that clean--maybe someone can helps to remove extra text from files. Put this in a batch file--let's call it ee1.Bat
@Echo Off
Set Server=YourServerName
net view \\%Server% >C:\Utils\%Server%.Txt
for /F "skip=1 tokens=1 delims=," %%i in (C:\Utils\%Server%.Txt) do dir /ad \\%Server%\%%i

Now save it and then from a command ling type ee1 >results.txt
The net view \\%Server% >C:\Utils\%Server%.Txt will have more info than we need, with heading and the like so maybe someone can help to clean up this file.
The "for /F "skip=1 tokens=1 delims=,"" will then go through that file do a dir of just the top level folders (/ad and no /s) in that share. Using the @Echo Off provides the cleanest output but with some tweaking the results.txt can be better.

Let me know if this is somewhat what you want--thanks.
0

Featured Post

Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question