Verification PING en PowerShell
Par Romain Tiennot le mardi 10 mai 2011, 14:51 - PowerShell - Lien permanent
Me revoilà encore avec mes scripts... Cette fois-ci en Powershell qui est plus adapté pour Windows 7 et Windows Serveur 2008/2008 R2.
Ce script effectue une vérification de réponse d'un serveur avec un Ping.
J'utilise cette vérification pour créer ma variable "$serveur" qui aura le nom ou l'IP d'un des serveurs en fonction.
Durant les différents tests du script, il va récupérer le statut de la réponse.
Voici le script :
$Reply = "" $serveur = "" $ping = new-object System.Net.NetworkInformation.Ping $Reply = $ping.Send("IP_SERVEUR_1") if ($Reply.status –eq “Success”) { $serveur = "IP_SERVEUR_1" } else { $ping = new-object System.Net.NetworkInformation.Ping $Reply = $ping.Send("IP_SERVEUR_2") if ($reply.status -eq "Success") { $serveur = "IP_SERVEUR_2" } else { exit } } write-host $serveur
A bientôt
Il y a 4 commentaires
Very informative post. Thanks for taking the time to share your view with us.
Thank You For This Post, was added to my bookmarks.
However development in technology, we have met various mobile some of the operators developing os which include iOS, Android and phones operating systems. Which phone manufacturer is selling more worldwide? http://www.moviesafar.com/z4root.ht... z4root download
Wow, wonderful weblog layout! How long have you been blogging for?
you made blogging look easy. The whole glance of your web site is
magnificent, as well as the content material!