Created
April 24, 2018 20:58
-
-
Save jaredcnance/e1586af786eb480dd8ff18e86f1cdab8 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
$Total = Invoke-Command -ScriptBlock {netsh int ipv4 show dynamicport tcp} | |
$regex = new-object System.Text.RegularExpressions.Regex ('(Number of Ports : )(\d*)', [System.Text.RegularExpressions.RegexOptions]::MultiLine) | |
$Total = ($regex.Match($Total)).Groups[2].Value | |
$InUse = Invoke-Command -ScriptBlock {(netstat -an | ? {($_ -notmatch 'LISTENING')}).Count} | |
Write-Output “$InUse/$Total ports in use” |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment