Created
June 25, 2018 16:35
-
-
Save guitarrapc/897831594ecd42a17786109124c58b96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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