< Back

Get-NetworkConnection

Sat Jan 18, 2020 5:03 pm

NAME Get-NetworkConnection



SYNOPSIS

Gets network connections on local host.





SYNTAX

Get-NetworkConnection [[-ProcessName] <String[]>] [-ProcessId <Int32[]>] [[-State] <String>] [<CommonParameters>]





DESCRIPTION

The Get-NetworkConnection cmdlet gets the active TCP/UDP connections on the local hostand returns them as a list

of NetworkConnection objects.





PARAMETERS

-ProcessName [<String[]>]

Filters the connections by process name.



Required? false

Position? 0

Default value

Accept pipeline input? true(ByValue,ByPropertyName)

Accept wildcard characters? false



-ProcessId [<Int32[]>]

Filters the connections by process id.



Required? false

Position? named

Default value

Accept pipeline input? true(ByPropertyName)

Accept wildcard characters? false



-State [<String>]

Filters the connections state.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS











OUTPUTS











Example 1: Get all active TCP/UDP connections.



PS C:\\>Get-NetworkConnection



This command lists all active TCP/UDP connections.

Example 2: Get all active TCP/UDP connections with process name svchost.



PS C:\\>Get-NetworkConnection -ProcessName svchost



This command lists all active TCP/UDP connections with process name svchost.

Example 3: Get all active TCP/UDP connections with process name svchost through pipeline.



PS C:\\>svchost | Get-NetworkConnection



This command lists all active TCP/UDP connections with process name svchost.

Example 4: Get all active TCP/UDP connections with process name Skype and stop the related processes.



PS C:\\>Get-NetworkConnection -ProcessName Skype | Stop-Process



First it gets all processes that has the name Skype, then it pipes it to Stop-Processes which in turn stops the

processes.



RELATED LINKS