Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function Get-NetTCPConnectionCheck{
[CmdletBinding()]
param(
)
begin
{
$result = @{}
}
process
{
$result.date = (Get-Date).ToString("yyyy/MM/dd HH:mm:dd:ss")
$connection = Get-NetTCPConnection
$statuslist = @("Listen","Established","TimeWait","CloseWait","LastAck")
$status = ($connection | group state -NoElement | where Name -in $statuslist).Name
foreach ($c in $($connection | group State -NoElement))
{
$status | %{
$s = $_
if (($c | where Name -eq $s).Name -ne $null)
{
$result.Add("$(($c | where Name -eq $s).Name)", ($c | where Name -eq $s).count)
}
}
}
}
end
{
return [PSCustomObject]$result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.