?
Solved

file share and directory report

Posted on 2014-04-08
10
Medium Priority
?
457 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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 43

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 40

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

The Ideal Solution for Multi-Display Applications

Check out ATEN’s VS1912 12-Port DP Video Wall Media Player at InfoComm 2017. Kerri describes how easy it is to design creative video walls in asymmetric layouts and schedule detailed playlists ahead of time with its advanced scheduling feature.

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In this article, we’ll look at how to deploy ProxySQL.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 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