PING TEST

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 9 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
shamir
Posts: 124
Last visit: Thu Sep 10, 2015 1:49 am

PING TEST

Post by shamir »

Hi,

I have created a basic FORM to check the ping result of 03 servers.

Question:-
Once I click on the PING button I should get the status of those 02 servers in the text boxes (FORM screenshot attached) whether the machine is ACTIVE or NOT-ACTIVE.

Please help me with the command lines.

Thnx
Attachments
INT.JPG
INT.JPG (17.75 KiB) Viewed 3388 times
User avatar
SAPIEN Support Forums
Posts: 945
Last visit: Thu Oct 22, 2015 1:10 pm

PING TEST

Post by SAPIEN Support Forums »

This is an automated post. A real person will respond soon.

Thank you for posting, shamir.

Here are some hints to help you get an accurate and complete answer to your question.

Ask in the best forum: If you asked in the wrong forum, just copy your question to the right forum.

Anticipate follow-up questions!

Did you remember to include the following?
  • 1. Product, version and build
    2. 32 or 64 bit product
    3. Operating system, e.g. Windows 7 64 bit.
    4. Attach a screenshot, if applicable
    5. Attach logs, crash reports, etc., in a ZIP file
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***
User avatar
shamir
Posts: 124
Last visit: Thu Sep 10, 2015 1:49 am

Re: PING TEST

Post by shamir »

Server Names:

Domain Controller: DC01 (192.168.10.1)
HyperV : HYPERSRV (192.168.10.2)
EMAIL Server : EXCHG (192.168.10.3)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PING TEST

Post by jvierra »

Shamir. What is your question?
User avatar
sapaju
Posts: 4
Last visit: Mon Feb 02, 2015 10:10 pm

Re: PING TEST

Post by sapaju »

Something like this.

Code: Select all

$DC = '192.168.10.1'

if (Test-Connection $DC -Count 1 -Quiet)
{
    Write-Output "DC ACTIVE"
}
else
{
    Write-Output "DC INACTIVE"
}
You can also use computer names, like dc.domain.tld instead of IP addresses. Also assign ACTIVE/INACTIVE text to your textbox instead of Write-Output.

This blog post should help: http://www.sapien.com/blog/2014/12/15/d ... tion-copy/
User avatar
jerrisheaton
Posts: 19
Last visit: Tue Mar 09, 2021 6:35 pm

Re: PING TEST

Post by jerrisheaton »

Looks like you almost go it. All you need to do now is instead of writing it to output, you change the text of the textbox.

You can do this by calling the textbox by name and modifying the .text property like this:
PowerShell Code
Double-click the code block to select all.
$buttonPing_Click={

    $DC = '192.168.10.1'
    $HYPERSRV = '192.168.10.2'
    $EXCHG = '192.168.10.3'

    if (Test-Connection $DC -Count 1 -Quiet)
    {
        $Textbox1.Text = "DC ACTIVE"
    }
    else
    {
        $Textbox1.Text = "DC INACTIVE"
    }

    if (Test-Connection $HYPERSRV -Count 1 -Quiet)
    {
        $Textbox2.Text = "HYPERSRV ACTIVE"
    }
    else
    {
        $Textbox2.Text = "HYPERSRV INACTIVE"
    }

    if (Test-Connection $EXCHG -Count 1 -Quiet)
    {
        $Textbox3.Text = "EXCHG ACTIVE"
    }
    else
    {
        $Textbox3.Text = "EXCHG INACTIVE"
    }
}
User avatar
shamir
Posts: 124
Last visit: Thu Sep 10, 2015 1:49 am

Re: PING TEST

Post by shamir »

Thanks All
This topic is 9 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked