You can use the pipeline for this. Instead of intermixing a string into the "Success" data stream, which would make getting all of the results into a usable CSV, try something like this:
Import-Csv "C:\test\Servercoll.txt" |
ForEach-Object {
$sname = $_.Servername # preserve name for any errors
Try{
Get-Service -computername $_.Servername -ErrorAction STOP |
Where-Object {$_.StartType -like "Automatic"} |
Select-Object Status,DisplayName,StartType,Machinename
}
Catch{
[PSCustomObject]@{
Status = "Unable to connect to the Computer" # maybe use "$_.Exception" instead of a fixed text
DisplayName = ""
StartType = ""
Machinename = $sname
}
}
} | Export-Csv -Path "C:\test\Services.csv" -NoTypeInformation