Răsfoiți Sursa

add logging to uninstall-package

Tobias Simetsreiter 2 ani în urmă
părinte
comite
8ee4d4480e
1 a modificat fișierele cu 5 adăugiri și 3 ștergeri
  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