Ver código fonte

fix monitor logic

Tobias Simetsreiter 4 anos atrás
pai
commit
e54e43865d
1 arquivos alterados com 2 adições e 1 exclusões
  1. 2 1
      Monitor_http.ps1

+ 2 - 1
Monitor_http.ps1

@@ -5,6 +5,7 @@ param(
 
 
 $Date = Get-Date
 $Date = Get-Date
 
 
+mkdir -Force ".\logs" | Out-Null
 $logfile = ".\logs\Monitor_http_{0}-{1}-{2}.log" -f ($Date.Year,$Date.Month,$Date.Day)
 $logfile = ".\logs\Monitor_http_{0}-{1}-{2}.log" -f ($Date.Year,$Date.Month,$Date.Day)
 
 
 Function main(){
 Function main(){
@@ -19,7 +20,7 @@ try {
     $success = $false
     $success = $false
 }
 }
 
 
-if ((-not $success) -and $Response.StatusCode -ne 200){
+if ((-not $success) -or $Response.StatusCode -ne 200){
     "Stopping Service ${ServiceName}"
     "Stopping Service ${ServiceName}"
     net stop  $ServiceName
     net stop  $ServiceName
     "Stopped Service ${ServiceName}"
     "Stopped Service ${ServiceName}"