1
Good afternoon! I have a simple powershell scritp that performs the connection test between Omains controllers and their respective service ports as below:
$servers = Get-Content -Path 'C:\DC Health\Domains_Controllers.txt'
$IP_TCPs = Get-Content -Path 'C:\DC Health\TCP_Ports.txt'
foreach($IP_TCP in $IP_TCPs){
foreach($server in $servers){
$socket = New-Object Net.Sockets.tcpClient
Try{
$socket.Connect($server, $IP_TCP)
Write-Host $server $IP_TCP Conectado
}
Catch{
Write-Host $server $IP_TCP Desconectado
}
Finally{
$socket.Close()
$socket.Dispose()
}
}
}
I wanted to have the output in some file like . txt or . csv, but the file always comes out blank. Is there any possibility of amending or adding to this exit? Thanks in advance.