Update Microsoft/PingCheck.ps1
This commit is contained in:
parent
6bc3ccbc1f
commit
09daf9aa3a
|
|
@ -1,46 +1,46 @@
|
||||||
### PowerShell Script, written by Arne.thiel[at]avast.com, 07.02.2018
|
### PowerShell Script, written by Arne.thiel[at]avast.com, 07.02.2018
|
||||||
### influenced by https://www.windowspro.de/script/test-connection-ping-powershell-senden
|
### 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
|
###https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/test-connection?view=powershell-6
|
||||||
|
|
||||||
# Variablen Deklarieren welche via Managed Workplace abgefragt werden
|
# Variablen Deklarieren welche via Managed Workplace abgefragt werden
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
[string]$DestinationIP1
|
[string]$DestinationIP1
|
||||||
)
|
)
|
||||||
|
|
||||||
## Anlegen einer Funktion Pingcheck
|
## Anlegen einer Funktion Pingcheck
|
||||||
|
|
||||||
Function Pingcheck
|
Function Pingcheck
|
||||||
{
|
{
|
||||||
$objres = Test-Connection -ComputerName $DestinationIP1 -Count 6 -Quiet
|
$objres = Test-Connection -ComputerName $DestinationIP1 -Count 6 -Quiet
|
||||||
|
|
||||||
if($objres -eq $false){Write-Host "Host $DestinationIP1 nicht ereichbar!"}
|
if($objres -eq $false){Write-Host "Host $DestinationIP1 nicht ereichbar!"}
|
||||||
ElseIf ($objres -eq $true) {Write-Host "Host $DestinationIP1 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
|
# Prüfen on die Ereignisanzeigen Quelle Managed Workplace Eventlog bereits existiert, falls nicht, wird diese erzeugt
|
||||||
|
|
||||||
if (!(Get-EventLog -LogName "Application" -Source "Managed Workplace”)){
|
if (!(Get-EventLog -LogName "Application" -Source "Managed Workplace”)){
|
||||||
New-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
|
## Erzeugen von Abfrage ob Zielgerät verfügbar ist und schreiben der Ereignisanzeige
|
||||||
|
|
||||||
if ($objres -eq $true)
|
if ($objres -eq $true)
|
||||||
{Write-EventLog –LogName Application –Source “Managed Workplace” –EntryType Information –EventID 15 –Message “System: $DestinationIP1 erreichbar: Test-Connection $res"}
|
{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"}
|
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:
|
## Ausführen der oben angelegten Funktion:
|
||||||
|
|
||||||
pingcheck ($DestinationIP1)
|
pingcheck ($DestinationIP1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in a new issue