Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

HOW TO USE LOOP INSIDE A Button.add_Click()

$
0
0

this is the code This do the work at one time only . I WANT  TO DO ONE ONE Kindly Help me

$btn.Add_Click({
#########NGM############
If (Test-Connection 192.168.35.9 -Quiet -Count 3)

{
$btn1.Backcolor="GREEN"
}

else

{$btn1.Backcolor="RED"} 

###########KPK############

If (Test-Connection 192.168.35.249 -Quiet -Count 1)

{
$btn2.Backcolor="GREEN"
}

else

{$btn2.Backcolor="RED"}


#########ANN##########

If (Test-Connection 192.168.35.201 -Quiet -Count 1)

{
$btn3.Backcolor="GREEN"
}

else

{$btn3.Backcolor="RED"}

###########ANR#############

If (Test-Connection 192.168.35.241 -Quiet -Count 1)

{
$btn4.Backcolor="GREEN"
}

else

{$btn4.Backcolor="RED"}


##############VBM################

If (Test-Connection 192.168.35.242 -Quiet -Count 1)

{
$btn5.Backcolor="GREEN"
}

else

{$btn5.Backcolor="RED"}

###############KKN############

If (Test-Connection 192.168.35.243 -Quiet -Count 1)

{
$btn6.Backcolor="GREEN"
}

else

{$btn6.Backcolor="RED"}

############POR################

If (Test-Connection 192.168.35.206 -Quiet -Count 1)

{
$btn7.Backcolor="GREEN"
}

else

{$btn7.Backcolor="RED"}

#############NGN##############

If (Test-Connection 192.168.35.207 -Quiet -Count 1)

{
$btn8.Backcolor="GREEN"
}

else

{$btn8.Backcolor="RED"}

###########VEL################

If (Test-Connection 192.168.35.207 -Quiet -Count 1)

{
$btn9.Backcolor="GREEN"
}

else

{$btn9.Backcolor="RED"}


##############ADY#############

If (Test-Connection 192.168.35.176 -Quiet -Count 1)

{
$btn10.Backcolor="GREEN"
}

else

{$btn10.Backcolor="RED"}


#########APT#################

If (Test-Connection 192.168.35.218 -Quiet -Count 1)

{
$btn11.Backcolor="GREEN"
}

else

{$btn11.Backcolor="RED"}


##########MYL#################

If (Test-Connection 192.168.35.217 -Quiet -Count 1)

{
$btn12.Backcolor="GREEN"
}

else

{$btn12.Backcolor="RED"}


}  
)


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>