Last active
April 9, 2022 14:21
-
-
Save kissge/6878da52bf2359adb99cf6de239892bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) | |
{ | |
# Relaunch as an elevated process: | |
Start-Process powershell.exe "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs | |
exit | |
} | |
$set = @{} | |
while ($true) { | |
(netstat -bano -p tcp | Select -skip 4) -join "`n" -split "(?= [TU][CD]P\s+(?:\d+\.|\[\w*:\w*:))" | | |
% { | |
$key = $_.trim() -replace "`n", ' ' -replace '\*\:\*', '*:*,' -replace '\s{2,}', ',' | |
if (-Not $set.ContainsKey($key)) { | |
echo $key | |
$set[$key] = $true | |
} | |
} | |
if([console]::KeyAvailable) { | |
break | |
} | |
} | |
$TempFile = New-TemporaryFile | Rename-Item -NewName { $_.Name -replace '.tmp', '-legalscape-debug.txt' } -Passthru | |
echo $set.keys > $TempFile | |
Start-Process -FilePath C:\Windows\explorer.exe -ArgumentList "/select, ""$TempFile""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment