Forum Discussion

phantom2000's avatar
phantom2000
Copper Contributor
Mar 22, 2022

Get result under a column

Hello, 

 

I have a command that checks connectivity to a port. 

 

Test-NetConnection -ComputerName google.com -Port 443 | Select-Object TcpTestSucceeded

The result for this comes as follows. 

TcpTestSucceeded
----------------
            True

 

I only want the result "True" put into a variable for later use. How can I achieve this?

 

Thanks in advance. 

  • $x=(Test-NetConnection -ComputerName google.com -Port 443 | Select-Object TcpTestSucceeded).TcpTestSucceeded
  • farismalaeb's avatar
    farismalaeb
    Steel Contributor
    $x=(Test-NetConnection -ComputerName google.com -Port 443 | Select-Object TcpTestSucceeded).TcpTestSucceeded

Resources