Marc B.,
Welcome to the forum. 
PowerShell is made for administrators - not programmers.
So a lot of explicit techniques you need in other programming or scripting languages are done implicitly by PowerShell for you without the need for you to even think about …
I’d recommend to do a step back and learn the fundamentals of PowerShell first. There you will learn that PowerShell has its built in help system where you find all needed basic information.
For example - you can run
Get-Help about_foreach
to get help for the foreach statement. You could add -ShowWindow to get it in a separate window for better readabilty - you can zoom it or search in it.
Get-Help about_foreach -ShowWindow
And for a lot of cmdlets you can add the paramter -Online to open the online version of the help where you can jump to other linked help topics if you need
Get-Help ForEach-Object -Online
You should ALWAYS read the help for the cmdlets you’re about to use completely including the examples to learn how to use them. 
To get an array of items you enumerate in PowerShell you can simply assign the output of the enumeration to a variable. PowerShell will make it an array automatically if there are more than one elements:
$FolderList =
(New-Object -ComObject 'Shell.Application').Windows() |
ForEach-Object {
$_.Document.Folder.Self.Path
}
… you can cast the output to an array even if there’s only one element in it with the array sub-expression operator @() …
$FolderList = @(
(New-Object -ComObject 'Shell.Application').Windows() |
ForEach-Object {
$_.Document.Folder.Self.Path
}
)
And BTW: When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance
How to format code in PowerShell.org <---- Click
