Exploring Powershell Commandlets

satya - 12/21/2019, 5:31:34 PM

Test-NetConnection

Test-NetConnection

satya - 12/21/2019, 5:46:32 PM

Some examples


//Ping by default: internetbeacon.msedge.net
Test-NetConnection


//with a port
Test-NetConnection -Port 80 -InformationLevel Detailed

//more stuff
Test-NetConnection -ComputerName www.contoso.com 

//Ping the RDP port
Test-NetConnection ipaddress -CommanTCPPort RDP 

//Ping the HTTP port
Test-NetConnection ipaddress -CommanTCPPort HTTP

//This seem to be ok
Test-NetConnection ipaddress -TraceRoute 

//but not this
Test-NetConnection ipaddress -CommanTCPPort HTTP -TraceRoute

//TraceRoute and Port seem to be in conflict 
//as parameters

satya - 12/21/2019, 5:49:16 PM

Other useful commands


ping
tracert

satya - 12/21/2019, 5:49:33 PM

ping to a specific port

ping to a specific port

Search for: ping to a specific port

satya - 12/21/2019, 5:53:26 PM

SOF question: ping and ports

SOF question: ping and ports

satya - 12/21/2019, 5:53:35 PM

Understand netstat

Understand netstat

Search for: Understand netstat

satya - 12/21/2019, 6:04:09 PM

Select-Sttring: grep of powershell. kind of...

Select-Sttring: grep of powershell. kind of...

satya - 12/21/2019, 6:11:00 PM

One way to convert object to strings


//This may not yield good results
//Pick an alias line that looks like
alias | Select-String "blah"


//Convert first to long lines
//by concatenating columns
alias | foreach {Write-Host $_.CommandType $_.Name} 

//Notice the {} vs ()
then you can pipe that to

| Select-String "someblah"