Powershell, power woaws
Go to solution
Solved by UK-Gary,
For all those who'd like the answer -
$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

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now