Here’s a fairly straightforward way of outputting the errors if the StartService method failed. It doesn’t take any action, just displays the error on screen. The WMI methods return Win32 error codes, so you can translate them into useful error messages via the Win32Exception class.
Get-WmiObject win32_service -Filter "startmode = 'auto' and state != 'running'" -computername (Get-Content C:\ServerList.txt) | ForEach-Object { $result = $_.StartService() if ($result.ReturnValue -ne 0) { $exception = New-Object System.ComponentModel.Win32Exception([int]$result.ReturnValue) Write-Host -ForegroundColor Red "Server: $($_.__SERVER), Error code: $($result.ReturnValue), Message: $($exception.Message)" } }