From ec87fa04bbdbca038e3a0e5f645fd7e67cd5ca4a Mon Sep 17 00:00:00 2001 From: Timur Date: Mon, 24 Jun 2024 07:29:03 +0000 Subject: [PATCH] Ping check --- PingCheck.ps1 | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 PingCheck.ps1 diff --git a/PingCheck.ps1 b/PingCheck.ps1 new file mode 100644 index 0000000..8fe2c68 --- /dev/null +++ b/PingCheck.ps1 @@ -0,0 +1,46 @@ +### PowerShell Script, written by Arne.thiel[at]avast.com, 07.02.2018 +### influenced by https://www.windowspro.de/script/test-connection-ping-powershell-senden +###https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/test-connection?view=powershell-6 + +# Variablen Deklarieren welche via Managed Workplace abgefragt werden + +Param( +[string]$DestinationIP1 +) + +## Anlegen einer Funktion Pingcheck + +Function Pingcheck +{ +$objres = Test-Connection -ComputerName $DestinationIP1 -Count 6 -Quiet + + if($objres -eq $false){Write-Host "Host $DestinationIP1 nicht ereichbar!"} + ElseIf ($objres -eq $true) {Write-Host "Host $DestinationIP1 ereichbar!"} + + # Prüfen on die Ereignisanzeigen Quelle Managed Workplace Eventlog bereits existiert, falls nicht, wird diese erzeugt + +if (!(Get-EventLog -LogName "Application" -Source "Managed Workplace”)){ +New-EventLog –LogName Application –Source “Managed Workplace” +} + +## Erzeugen von Abfrage ob Zielgerät verfügbar ist und schreiben der Ereignisanzeige + + if ($objres -eq $true) +{Write-EventLog –LogName Application –Source “Managed Workplace” –EntryType Information –EventID 15 –Message “System: $DestinationIP1 erreichbar: Test-Connection $res"} +else {Write-EventLog –LogName Application –Source “Managed Workplace” –EntryType Warning –EventID 155 –Message "System: $DestinationIP1 nicht erreichbar: Test-Connection $res"} + +} + +## Ausführen der oben angelegten Funktion: + +pingcheck ($DestinationIP1) + + + + + + + + + +