Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Created June 25, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/897831594ecd42a17786109124c58b96 to your computer and use it in GitHub Desktop.
Save guitarrapc/897831594ecd42a17786109124c58b96 to your computer and use it in GitHub Desktop.
function Get-NetTCPConnectionCheck{
[CmdletBinding()]
param(
)
begin
{
$result = [ordered]@{}
}
process
{
$result.date = (Get-Date).ToString("yyyy/MM/dd HH:mm:dd:ss")
$connection = Get-NetTCPConnection
$status = ($connection | group state -NoElement).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