Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

powershel lto get the names of folders on a server share

Posted on 2014-11-25
7
Medium Priority
?
300 Views
Last Modified: 2014-11-25
Hello, I need to figure out the contents of a folder share , I need to get the folder names of the folders in that share , then export them to a csv file.

so if the folder share is \\servername\e$
 then I like the script to give me a list of folders say starting with a like name of ABC so that I get all folders starting with ABC in that share
0
Comment
Question by:gd6627
  • 4
  • 2
7 Comments
 
LVL 29

Accepted Solution

by:
becraig earned 2000 total points
ID: 40464994
gci \\servername\e$  | ? {($_.psIsContainer ) -and ($_.name -like "ABC*")} | select Name | export-csv c:\file.csv -nti

Open in new window


Something like above should do
0
 
LVL 19

Expert Comment

by:Montoya
ID: 40464995
try dir | where {$_.PsIsContainer}


There's a great article here:
http://blogs.msdn.com/b/powershell/archive/2006/06/24/645000.aspx

That goes deeper.
0
 
LVL 29

Expert Comment

by:becraig
ID: 40465001
I need to edit
gci \\servername\e$ -recurse  | ? {($_.psIsContainer ) -and ($_.name -like "ABC*")} | select Name | export-csv c:\file.csv -nti

Open in new window

                                         
I forgot to recurse.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gd6627
ID: 40465037
Thanks guys ,

Becraig how do I get it so that I don't get the mode and the last write times I just need the names of the folders
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 2000 total points
ID: 40465051
My script should give you just that, since we are using "select" to select only the name:

gci \\servername\e$ -recurse  | ? {($_.psIsContainer ) -and ($_.name -like "ABC*")} | select Name | export-csv c:\file.csv -nti

Open in new window

                                         
You can also substitute "Fullname" for "name"  if you want to get the full path.
0
 

Author Closing Comment

by:gd6627
ID: 40465063
thank you so much
0
 
LVL 29

Expert Comment

by:becraig
ID: 40465066
Happy to help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

772 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