Please when you post code or console output format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the buutton and paste your code.
Besides that please do not use aliasses in scripts and especially not in forums as it makes your code harder to read.
Thanks in advance.
So you actually need to run this endlessly, right?
Assumed tnc stands for Test-NetConnection you can create a loop and check the output with a condition. A simple version would be something like this:
$log = do # Do this
{
# Store the result of TNC in this variable to be tested until(...) is False
$tnc = Test-NetConnection -ComputerName [Address]
] -Port [port] |
Select-Object @{
Name = 'TimeStamp'
Expression = { [datetime]::Now.ToString('u') }
}, RemoteAddress, RemotePort, TcpTestSuceeded
# Return this variable so it's captured in $log Variable to export the log later
$tnc
Start-Sleep -Seconds 5
}
until ($tnc.TcpTestSuceeded) # Until this property is $False
$log | Export-Csv path/to/logfile.csv -NoTypeInformation
But thank you very much for taking the time to come back to me.Preformatted text