Solved

powershel lto get the names of folders on a server share

Posted on 2014-11-25
7
284 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 28

Accepted Solution

by:
becraig earned 500 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:Iammontoya
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 28

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
 

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 28

Assisted Solution

by:becraig
becraig earned 500 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 28

Expert Comment

by:becraig
ID: 40465066
Happy to help.
0

Join & Write a Comment

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now