We help IT Professionals succeed at work.

powershell folder structure command - csv output

pma111
pma111 asked
on
105 Views
1 Endorsement
Last Modified: 2018-12-05
is there a way via powershell to supply a file share path e.g. \\server\share\directory and it report all sub directories (but only folders), and sub directories within those, out to a csv file? a bit similar to the old windows DIR command, but to not show all files within folders, only folder details

e.g. if I supply \\server\share - I get a report of all folders (as deep into the structure they go, but no more detail, e.g. files etc.

\\server\share\directory1
\\server\share\directory1\subdir1
\\server\share\directory1\subdir2
\\server\share\directory2
\\server\share\directory2\subdir1
\\server\share\directory2\subdir2
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
AlexA lack of information provides a lack of a decent solution.
CERTIFIED EXPERT

Commented:
$Directory = "./"
Get-ChildItem $Directory -Recurse | % {
    if ($_.Attributes -eq "Directory") {
        Write-Host $_.FullName
    }
}

Open in new window

THat works too, you could even wrap it in a function, let me know if you want that and then you can add it to your powershell folder to have it all the time, I could probably code it so you can use something like get-directory "Share or location"
aikimarkSocial distance; Wear a mask; Don't touch your face; Wash your hands for 20 seconds
CERTIFIED EXPERT
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.