after that I found from Internet,
You only need to add
Tee-object -FilePath C:\Users\engsooncheah\Desktop\PS\Aport2_log.txt
Sample code
$TestResults = Test-Connection -ComputerName 8.8.8.8 -Count 10| Tee-object -FilePath C:\Users\engsooncheah\Desktop\PS\Aport2_log.txt
1
solved How to get the log of Ping via PowerShell