Link to home
Start Free TrialLog in
Avatar of Pau Lo
Pau Lo

asked on

powershell folder structure command - csv output

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
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
$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"
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial