'Separator(Write-Host) not recognised (Powershell)

Separator(Write-Host) (here) for BLANK whitespaces is not recognized when using it to display DELAYED output.

How to display spaces within list elements?

CODE

Write-Host "Started"
$startnum  = 1
$endnum  =  10
$list = $startnum..$endnum
$count = 0 
Clear-Host
while($count -le $endnum){
    Write-Host $list[$count]  -NoNewline -Separator " " //<--not recognized
    Start-Sleep 2
    $count++
}
Clear-Host
Write-Host "Finished"

OUTPUT (Separator " " not recognized)

12345678910 


Solution 1:[1]

The -Separator is honored when you write out an array (one write process, many items).

Write-Host (1..10) -Separator " "

When you do the opposite (multiple write processes, one item each), make a string that contains a space at the end.

foreach ($i in 1..10) {
    Write-Host "$i " -NoNewline
    Start-Sleep -Milliseconds 250
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tomalak