PowerShell output saved to file location

Hi everyone.
Hoping someone could offer me some advice in regards to an issue I am stuck on.

My script checks the Tempdb status , I would like the results to a .csv and also display on screen if possible.
If possible could someone advise me on what I need to change in my script , how the options work etc.

Any comments on how the script is working , and how I can change it would be most appreciated as I am trying to learn PowerShell.

My current script:

foreach ($svr in get-content "C:\PowerShell\Servers.txt")

function Test-SQLConnection{
param([parameter(mandatory=$true)][string[]] $Instances)

$return = @()
foreach($InstanceName in $Instances){
$row = New-Object –TypeName PSObject –Prop @{'InstanceName'=$InstanceName;'StartupTime'=$null}
$check=Invoke-Sqlcmd -ServerInstance $InstanceName -Database TempDB -Query "SELECT @@SERVERNAME as Name,Create_Date FROM sys.databases WHERE name = 'TempDB'" -ErrorAction Stop -ConnectionTimeout 3
$row.InstanceName = $check.Name
$row.StartupTime = $check.Create_Date
#do nothing on the catch
$return += $row
return $return

Test-SQLConnection -Instances $svr


thank you in advance for any advice offered.