I have a list of servers to which I should have access. I know that to some of them I have not. I want to check access to each server and list only that ones to which I do not have access. To do that I created script which for each server use test-netconnection
function to check if I am able to connect and then I use if
statement to write server name to the file if the test was not successful. Unfortunately seems that if
does not work as I expected.
Could you please advice what I am doing wrong with the example below?
I run the below script
$test_result.TcpTestSucceeded
if($test_result.TcpTestSucceeded -eq 'False' )
{
Write-Output 'a'
}
else
{
Write-Output 'b'
}
and I have the below result
As you can see even-though value is true
powershell choose option a
, while I would expect that option b
should be displayed.