Powershell Parsing Help – How to output a list of folder names into a text file

Question:

I have a simple script that reads the folder names and outputs them into a text file. I realized I got a lot more output then I wanted, so I used the select-item cmdlet to select just the name property from the hashtable. The problem is that there is still all the white space that the data I omitted would have normally filled, not helping my problem since the white space will destroy my script.

I have tried some [regex] commands to strip out the whitespace with (/S+) but I don’t really know it that well I was using some code trying to tweak from an example someone helped me with. The topic name is the same as the title here and it is on this site too. Anyone that can help me I would appreciate it!

Basically, I cant figure out how to output the names of folders into a simple text file with ZERO whitespace (1 line per folder name).


Answer:

Try this one:

Related resources:

Source:

Powershell Parsing Help – How to output a list of folder names into a text file by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply