$FileServerShares
already is an array (even without the [array]
specifier):
PS> $FileServerShares.getType() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Object[] System.Array
For some reason, when an array of share objects is converted to a string, each share is put on the same line. I don't know why that is, but what you could do is convert the share objects to strings so that you have an array of strings. String arrays do get converted to multiline strings.
$FileServer = "ServerName" $FileServerShares = gwmi win32_Share -ComputerName $FileServer | Where-Object {$_.type -eq '0'} | Where {$_.name -notlike "*$*"} | % { $_.ToString() } Write-Host $FileServerShares