Created
September 6, 2014 15:10
-
-
Save gigaherz/94050d6e2b76e9b7ba3a 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 SetupForm{ | |
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null; | |
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null; | |
$form = New-Object System.Windows.Forms.Form; | |
$dgv = New-Object System.Windows.Forms.DataGridView; | |
$form.Text = "TCP Connection Status"; | |
$form.Name = "form"; | |
$form.Controls.Add($dgv); | |
$dgv.Width = $form.Width - 10; | |
$dgv.Height = $form.Height | |
$dgv.Anchor = [System.Windows.Forms.AnchorStyles]::Left -bor [System.Windows.Forms.AnchorStyles]::Right -bor [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Top | |
$timer = New-Object System.Windows.Forms.Timer; | |
$timer.Interval = 1000; | |
$timer.add_Tick({ | |
$result = [System.Net.NetworkInformation.IpGlobalProperties]::GetIPGlobalProperties().GetActiveTcpConnections(); | |
$dgv.Datasource = $result; | |
}); | |
$timer.Enabled = $TRUE; | |
$form.Visible = $TRUE; | |
[System.Windows.Forms.Application]::Run($form); | |
} | |
SetupForm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment