Solved

powershel lto get the names of folders on a server share

Posted on 2014-11-25
7
289 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 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: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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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 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 29

Expert Comment

by:becraig
ID: 40465066
Happy to help.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This article will help you understand what HashTables are and how to use them in PowerShell.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
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 …

861 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

25 Experts available now in Live!

Get 1:1 Help Now