The first version of the tool was developed by Amandhally and it can be found in the below path. Thanks for sharing.
In my version of the tool, I’ve re-used his template and modified in such a way that the output is HTML formatted with server Names displayed in the result area.
You can download the second version of the tool by clicking the below link
http://gallery.technet.microsoft.com/PowerShell-GUI-Tool-f03b7523
This script requires
- Staring IP- Adddress
- Ending IP-Address
- Hit RUN button
- The output in the result box
You can also send email from the below portion of window
Output-
PowerShell Code:-
<#================================= # Generated On: 04/02/2014 # Generated By: Prashanth Jayaram # Version : 1.1 # Desc : Network Ping #================================= #> Function Network_Pinger { function OnApplicationLoad { #Note: This function is not called in Projects #Note: This function runs before the form is created #Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path #Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList) #Important: Form controls cannot be accessed in this function #TODO: Add snapins and custom code to validate the application load $PingReport = "C:\pingstatus.htm" New-Item -ItemType file $PingReport -Force return $true #return true for success or false for failure } function OnApplicationExit { #Note: This function is not called in Projects #Note: This function runs after the form is closed #TODO: Add custom code to clean up and unload snapins when the application exits $script:ExitCode = 0 #Set the exit code for the Packager } #endregion Application Functions #---------------------------------------------- # Generated Form Function #---------------------------------------------- function Call-PIng_Network_Community_v2_pff { #---------------------------------------------- #region Import the Assemblies #---------------------------------------------- [void][reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") [void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") [void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") #endregion Import Assemblies #---------------------------------------------- #region Generated Form Objects #---------------------------------------------- [System.Windows.Forms.Application]::EnableVisualStyles() $formPowershellNetworkPin = New-Object 'System.Windows.Forms.Form' $labelOutput = New-Object 'System.Windows.Forms.Label' $labelCreatedByAmanDhallyW = New-Object 'System.Windows.Forms.Label' $labelSubject = New-Object 'System.Windows.Forms.Label' $labelFrom = New-Object 'System.Windows.Forms.Label' $label1 = New-Object 'System.Windows.Forms.Label' $labelSMTPServer = New-Object 'System.Windows.Forms.Label' $textbox9 = New-Object 'System.Windows.Forms.TextBox' $textbox8 = New-Object 'System.Windows.Forms.TextBox' $textbox7 = New-Object 'System.Windows.Forms.TextBox' $textbox6 = New-Object 'System.Windows.Forms.TextBox' $buttonEMailOutput = New-Object 'System.Windows.Forms.Button' $richtextbox1 = New-Object 'System.Windows.Forms.RichTextBox' $buttonRun = New-Object 'System.Windows.Forms.Button' $textbox5 = New-Object 'System.Windows.Forms.TextBox' $labelTo = New-Object 'System.Windows.Forms.Label' $textbox4 = New-Object 'System.Windows.Forms.TextBox' $textbox3 = New-Object 'System.Windows.Forms.TextBox' $textbox2 = New-Object 'System.Windows.Forms.TextBox' $textbox1 = New-Object 'System.Windows.Forms.TextBox' $labelIPAddressRange = New-Object 'System.Windows.Forms.Label' $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' #endregion Generated Form Objects $formPowershellNetworkPin_Load={ #TODO: Initialize Form Controls here } $textbox1.MaxLength=3 $textbox2.MaxLength=3 $textbox3.MaxLength=3 $textbox4.MaxLength=3 $textbox5.MaxLength=3 function Get-ComputerNameByIP { param( $IPAddress = $null ) BEGIN { } PROCESS { if ($IPAddress -and $_) { throw 'Please use either pipeline or input parameter' break } elseif ($IPAddress) { ([System.Net.Dns]::GetHostbyAddress($IPAddress)).HostName } elseif ($_) { [System.Net.Dns]::GetHostbyAddress($_).HostName } else { $IPAddress = Read-Host "Please supply the IP Address" [System.Net.Dns]::GetHostbyAddress($IPAddress).HostName } } END { } } $buttonRun_Click={ #TODO: Place custom script here $richtextbox1.Clear() $PingReport = "C:\pingstatus.htm" #$script:list = "c:\computer.txt" New-Item -ItemType file $PingReport -Force # Getting the freespace info using WMI #Get-WmiObject win32_logicaldisk | Where-Object {$_.drivetype -eq 3 -OR $_.drivetype -eq 2 } | format-table DeviceID, VolumeName,status,Size,FreeSpace | Out-File FreeSpace.txt # Function to write the HTML Header to the file Function writeHtmlHeader { param($fileName) $date = ( get-date ).ToString('yyyy/MM/dd') Add-Content $fileName "<html>" Add-Content $fileName "<head>" Add-Content $fileName "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>" Add-Content $fileName '<title>IP Scanner Report</title>' add-content $fileName '<STYLE TYPE="text/css">' add-content $fileName "<!--" add-content $fileName "td {" add-content $fileName "font-family: Tahoma;" add-content $fileName "font-size: 11px;" add-content $fileName "border-top: 1px solid #999999;" add-content $fileName "border-right: 1px solid #999999;" add-content $fileName "border-bottom: 1px solid #999999;" add-content $fileName "border-left: 1px solid #999999;" add-content $fileName "padding-top: 0px;" add-content $fileName "padding-right: 0px;" add-content $fileName "padding-bottom: 0px;" add-content $fileName "padding-left: 0px;" add-content $fileName "}" add-content $fileName "body {" add-content $fileName "margin-left: 5px;" add-content $fileName "margin-top: 5px;" add-content $fileName "margin-right: 0px;" add-content $fileName "margin-bottom: 10px;" add-content $fileName "" add-content $fileName "table {" add-content $fileName "border: thin solid #000000;" add-content $fileName "}" add-content $fileName "-->" add-content $fileName "</style>" Add-Content $fileName "</head>" Add-Content $fileName "<body>" add-content $fileName "<table width='100%'>" add-content $fileName "<tr bgcolor='#CCCCCC'>" add-content $fileName "<td colspan='2' height='25' align='center'>" add-content $fileName "<font face='tahoma' color='#003399' size='4'><strong>IP Scanner Report - $date</strong></font>" add-content $fileName "</td>" add-content $fileName "</tr>" add-content $fileName "</table>" } # Function to write the HTML Header to the file Function writeTableHeader { param($fileName) Add-Content $fileName "<tr bgcolor=#CCCCCC>" Add-Content $fileName "<td width='10%' align='center'>Name</td>" Add-Content $fileName "<td width='50%' align='center'>Status Label</td>" Add-Content $fileName "</tr>" } Function writeHtmlFooter { param($fileName) Add-Content $fileName "</body>" Add-Content $fileName "</html>" } Function writeDiskInfo { param($fileName,$name,$status) if ($status -eq $TRUE) { Add-Content $fileName "<tr>" Add-Content $fileName "<td>$Name</td>" Add-Content $fileName "<td>Is alive and Pinging</td>" } else { Add-Content $fileName "<tr>" Add-Content $fileName "<td>$Name</td>" Add-Content $fileName "<td bgcolor='#FF0000'>Seems dead and not Pinging</td>" Add-Content $fileName "</tr>" } } writeHtmlHeader $PingReport Add-Content $PingReport "<table width='100%'><tbody>" Add-Content $PingReport "<tr bgcolor='#CCCCCC'>" Add-Content $PingReport "<td width='100%' align='center' colSpan=2><font face='tahoma' color='#003399' size='2'><strong> IP and Host Status </strong></font></td>" Add-Content $PingReport "</tr>" $result = @() $startip = $textbox1.Text + "." + $textbox2.Text + "." + $textbox3.Text + "." + $textbox4.Text $ip = $textbox5.Text foreach ($i in $startip) { $last = $i.Split(".") [int]$lastip = $last[3] while ( $lastip -le $ip ) { $result += $textbox1.Text + "." + $textbox2.Text + "." + $textbox3.Text + "." + $lastip++ } } foreach ( $computer in $result ) { if (test-Connection -ComputerName $computer -Count 1 -Quiet ) { $Name= Get-ComputerNameByIP -IPAddress $computer $richtextbox1.Text += "$computer -> $Name is alive and Pinging." $richtextbox1.Text += "`n" writeDiskInfo $PingReport "$computer -> $Name" $TRUE $formPowershellNetworkPin.Refresh() } else { $richtextbox1.Text += " $computer -> seems dead and not Pinging." $richtextbox1.Text += "`n" writeDiskInfo $PingReport $computer $FALSE $formPowershellNetworkPin.Refresh() } } Add-Content $PingReport "</table>" } ##writeHtmlFooter $PingReport $buttonClear_Click={ #TODO: Place custom script here } Function sendEmail { param($from,$to,$subject,$smtphost,$htmlFileName) [string]$receipients="$to" $body = Get-Content $htmlFileName $body = New-Object System.Net.Mail.MailMessage $from, $receipients, $subject, $body $body.isBodyhtml = $true $smtpServer = $MailServer $smtp = new-object Net.Mail.SmtpClient($smtphost) $smtp.Send($body) } #Call Function #sendEmail -from $From -to $to -subject "System Report : $computers" -smtphost $SMTPMail -htmlfilename c:\report.html $buttonEMailOutput_Click={ #TODO: Place custom script here $smtp = $textbox6.Text $to = $textbox7.Text $from = $textbox8.Text $sub = $textbox9.Text $body = $richtextbox1.Text sendEmail -from $From -to $to -subject $sub -smtphost $smtp -htmlfilename c:\pingstatus.htm if($?) { [void][System.Windows.Forms.MessageBox]::Show("Email Sent") } } $labelSMTPServer_Click={ #TODO: Place custom script here } # --End User Generated Script-- #---------------------------------------------- #region Generated Events #---------------------------------------------- $Form_StateCorrection_Load= { #Correct the initial state of the form to prevent the .Net maximized form issue $formPowershellNetworkPin.WindowState = $InitialFormWindowState } $Form_Cleanup_FormClosed= { #Remove all event handlers from the controls try { $labelSMTPServer.remove_Click($labelSMTPServer_Click) $buttonEMailOutput.remove_Click($buttonEMailOutput_Click) $buttonRun.remove_Click($buttonRun_Click) $formPowershellNetworkPin.remove_Load($formPowershellNetworkPin_Load) $formPowershellNetworkPin.remove_Load($Form_StateCorrection_Load) $formPowershellNetworkPin.remove_FormClosed($Form_Cleanup_FormClosed) } catch [Exception] { } } #endregion Generated Events #---------------------------------------------- #region Generated Form Code #---------------------------------------------- # # formPowershellNetworkPin # $formPowershellNetworkPin.Controls.Add($labelOutput) $formPowershellNetworkPin.Controls.Add($labelCreatedByAmanDhallyW) $formPowershellNetworkPin.Controls.Add($labelSubject) $formPowershellNetworkPin.Controls.Add($labelFrom) $formPowershellNetworkPin.Controls.Add($label1) $formPowershellNetworkPin.Controls.Add($labelSMTPServer) $formPowershellNetworkPin.Controls.Add($textbox9) $formPowershellNetworkPin.Controls.Add($textbox8) $formPowershellNetworkPin.Controls.Add($textbox7) $formPowershellNetworkPin.Controls.Add($textbox6) $formPowershellNetworkPin.Controls.Add($buttonEMailOutput) $formPowershellNetworkPin.Controls.Add($richtextbox1) $formPowershellNetworkPin.Controls.Add($buttonRun) $formPowershellNetworkPin.Controls.Add($textbox5) $formPowershellNetworkPin.Controls.Add($labelTo) $formPowershellNetworkPin.Controls.Add($textbox4) $formPowershellNetworkPin.Controls.Add($textbox3) $formPowershellNetworkPin.Controls.Add($textbox2) $formPowershellNetworkPin.Controls.Add($textbox1) $formPowershellNetworkPin.Controls.Add($labelIPAddressRange) $formPowershellNetworkPin.ClientSize = '463, 326' $formPowershellNetworkPin.FormBorderStyle = 'Fixed3D' $formPowershellNetworkPin.Name = "formPowershellNetworkPin" $formPowershellNetworkPin.Opacity = 0.95 $formPowershellNetworkPin.StartPosition = 'CenterScreen' $formPowershellNetworkPin.Text = "Powershell IP Scanner" $formPowershellNetworkPin.add_Load($formPowershellNetworkPin_Load) # # labelOutput # $labelOutput.Location = '12, 44' $labelOutput.Name = "labelOutput" $labelOutput.Size = '65, 16' $labelOutput.TabIndex = 21 $labelOutput.Text = "Output |" # # # labelSubject # $labelSubject.Location = '163, 237' $labelSubject.Name = "labelSubject" $labelSubject.Size = '100, 20' $labelSubject.TabIndex = 18 $labelSubject.Text = "Subject" # # labelFrom # $labelFrom.Location = '17, 238' $labelFrom.Name = "labelFrom" $labelFrom.Size = '100, 19' $labelFrom.TabIndex = 17 $labelFrom.Text = "From" # # label1 # $label1.Location = '163, 188' $label1.Name = "label1" $label1.Size = '92, 23' $label1.TabIndex = 16 $label1.Text = "To" # # labelSMTPServer # $labelSMTPServer.Location = '17, 188' $labelSMTPServer.Name = "labelSMTPServer" $labelSMTPServer.Size = '150, 23' $labelSMTPServer.TabIndex = 15 $labelSMTPServer.Text = "SMTP Server" $labelSMTPServer.add_Click($labelSMTPServer_Click) # # textbox9 # $textbox9.Location = '163, 260' $textbox9.Name = "textbox9" $textbox9.Size = '150, 20' $textbox9.TabIndex = 14 # # textbox8 # $textbox8.Location = '12, 260' $textbox8.Name = "textbox8" $textbox8.Size = '150, 20' $textbox8.TabIndex = 13 # # textbox7 # $textbox7.Location = '163, 214' $textbox7.Name = "textbox7" $textbox7.Size = '150, 20' $textbox7.TabIndex = 12 # # textbox6 # $textbox6.Location = '12, 214' $textbox6.Name = "textbox6" $textbox6.Size = '150, 20' $textbox6.TabIndex = 11 # # buttonEMailOutput # $buttonEMailOutput.Location = '337, 214' $buttonEMailOutput.Name = "buttonEMailOutput" $buttonEMailOutput.Size = '65, 65' $buttonEMailOutput.TabIndex = 16 $buttonEMailOutput.Text = "E-Mail Output" $buttonEMailOutput.UseVisualStyleBackColor = $True $buttonEMailOutput.add_Click($buttonEMailOutput_Click) # # richtextbox1 # $richtextbox1.Location = '12, 63' $richtextbox1.Name = "richtextbox1" $richtextbox1.Size = '427, 101' $richtextbox1.TabIndex = 8 $richtextbox1.Text = "" # # buttonRun # $buttonRun.Location = '350, 20' $buttonRun.Name = "buttonRun" $buttonRun.Size = '55, 23' $buttonRun.TabIndex = 7 $buttonRun.Text = "Run" $buttonRun.UseVisualStyleBackColor = $True $buttonRun.add_Click($buttonRun_Click) # # textbox5 # $textbox5.Location = '303, 21' $textbox5.Name = "textbox5" $textbox5.Size = '28, 20' $textbox5.TabIndex = 6 # # labelTo # $labelTo.Location = '263, 23' $labelTo.Name = "labelTo" $labelTo.Size = '100, 23' $labelTo.TabIndex = 5 $labelTo.Text = "-- to --" # # textbox4 # $textbox4.Location = '228, 21' $textbox4.Name = "textbox4" $textbox4.Size = '27, 20' $textbox4.TabIndex = 4 # # textbox3 # $textbox3.Location = '192, 21' $textbox3.Name = "textbox3" $textbox3.Size = '27, 20' $textbox3.TabIndex = 3 # # textbox2 # $textbox2.Location = '157, 21' $textbox2.Name = "textbox2" $textbox2.Size = '27, 20' $textbox2.TabIndex = 2 # # textbox1 # $textbox1.Location = '123, 21' $textbox1.Name = "textbox1" $textbox1.Size = '27, 20' $textbox1.TabIndex = 1 # # labelIPAddressRange # $labelIPAddressRange.Location = '15, 21' $labelIPAddressRange.Name = "labelIPAddressRange" $labelIPAddressRange.Size = '112, 23' $labelIPAddressRange.TabIndex = 0 $labelIPAddressRange.Text = "IP-Address Range :" #endregion Generated Form Code #---------------------------------------------- #Save the initial state of the form $InitialFormWindowState = $formPowershellNetworkPin.WindowState #Init the OnLoad event to correct the initial state of the form $formPowershellNetworkPin.add_Load($Form_StateCorrection_Load) #Clean up the control events $formPowershellNetworkPin.add_FormClosed($Form_Cleanup_FormClosed) #Show the Form return $formPowershellNetworkPin.ShowDialog() } #End Function #Call OnApplicationLoad to initialize if((OnApplicationLoad) -eq $true) { #Call the form Call-PIng_Network_Community_v2_pff | Out-Null #Perform cleanup OnApplicationExit } } Network_Pinger