Using Powershell, i wanted to get a list of only folder names for a specified directory. I didn’t want the entire sub-folder tree for all of the folders, only the ‘top level’ folders.
The command get-childitem \\foldername –recurse would give me all of the files and subfolders.
The command get-childitem \\foldername\*\* will give me the root folder, the first layer of subfolders, and the second layer of subfolders.
To list only folder names, use get-childitem \\foldername\*\* –directory
To output this to a csv file use get-childitem \\foldername\*\* –directory | export-csv c:\outputfilename.csv