A resonable formatting would have helped you (and others) to understand your code much easier:
#Declare IP range
$range = 1..254
$address = "192.168.0."
#status
Write-Output "Scanning active PCs"
#Scan ip range and get pc names
$range |
ForEach-Object {
Write-Progress 'Scanning Network' $address$_ -PercentComplete (($_ / $range.Count) * 100)
Start-Sleep -Milliseconds 100
Get-WmiObject Win32_PingStatus -Filter "Address='192.168.0.$_' and Timeout=200 and ResolveAddressNames='true' and StatusCode=0 and ProtocolAddressResolved like '%.domain.com'" |
Select-Object -ExpandProperty ProtocolAddressResolved
} |
Out-File C:PowershellScriptsComputerList.txt
Write-Output does not generate any ouptut. So it does not make sense to pipe it to any other cmdlet.
If you really want to have 2 different and unrelated commands on one line you should separate them with a semikolon like Thomas already mentioned in the comments above.
That's the same for Start-Sleep by the way. I'd recommend to always read the complete help for the cmdlets you're about to use to learn how to use them.
To make your code easier to read you should use line breaks and indentation. Here is some more to read about: The PowerShell Best Practices and Style Guide
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…