I think you want to have one line with information, and then:
"$server Uptime: $($uptime.days) Days, $($uptime.hours) Hours, $($uptime.minutes) Minutes" | add-content $output_file
If each item should be on a separate line, you can add `n
"$server Uptime`n$($uptime.days) Days`n$($uptime.hours) Hours`n$($uptime.minutes) Minutes" | add-content $output_file
Another possibility is to use -f , which is sometimes more readable:
"$server Uptime: {0} Days, {1} Hours, {2} Minutes" -f $uptime.days, $uptime.hours, $uptime.minutes | add-content $output_file
Updating echo is an alias for Write-Output ( Get-Alias -name echo ), which in your case creates an array of objects. This array is passed to Add-Content ; each object is stored in its own line.
stej
source share