浏览代码

add logging to uninstall-package

Tobias Simetsreiter 2 年之前
父节点
当前提交
8ee4d4480e
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      bin/uninstall-package.ps1

+ 5 - 3
bin/uninstall-package.ps1

@@ -1,6 +1,7 @@
 param(
     $ComputerName,
-    $ProgramName
+    $ProgramName,
+    $LogFile="runtime/uninstall-package.log"
 )
 $ComputerName | Out-Host
 # $psremoteremote = Resolve-Path "$PSScriptRoot\..\localadmin\psremote-remote.ps1"
@@ -8,8 +9,9 @@ $ComputerName | Out-Host
 # &$psremoteremote -ComputerName $ComputerName
 
 # "NetPhone Client"
-Invoke-Command -ComputerName $ComputerName -ScriptBlock { 
+Invoke-Command -ComputerName $ComputerName -ScriptBlock {
+    hostname
     Get-Package |
     Where-Object {$_.Name -eq $ProgramName} |
     Uninstall-Package -Force
-}
+} *>&1 | Tee-Object -Append $LogFile