浏览代码

bugfix and tee output

Tobias Simetsreiter 4 年之前
父节点
当前提交
5c1244f635
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      Monitor_http.ps1

+ 3 - 3
Monitor_http.ps1

@@ -19,7 +19,7 @@ try {
     $success = $false
     $success = $false
 }
 }
 
 
-if ($success -and $Response.StatusCode -ne 200){
+if ((-not $success) -and $Response.StatusCode -ne 200){
     "Stopping Service ${ServiceName}"
     "Stopping Service ${ServiceName}"
     net stop  $ServiceName
     net stop  $ServiceName
     "Stopped Service ${ServiceName}"
     "Stopped Service ${ServiceName}"
@@ -33,7 +33,7 @@ if ($success -and $Response.StatusCode -ne 200){
 }
 }
 
 
 try {
 try {
-    main >> $logfile
+    main | Tee-Object $logfile -Append
 } catch {
 } catch {
-    $_.exception >> $logfile
+    $_.exception | Tee-Object $logfile -Append
 }
 }