Ping check
This commit is contained in:
parent
8cecbed071
commit
ec87fa04bb
46
PingCheck.ps1
Normal file
46
PingCheck.ps1
Normal file
|
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in a new issue