Просмотр исходного кода

pass argument to remote command

Tobias Simetsreiter 2 лет назад
Родитель
Сommit
36703ca2e6
1 измененных файлов с 4 добавлено и 7 удалено
  1. 4 7
      bin/uninstall-package.ps1

+ 4 - 7
bin/uninstall-package.ps1

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