فهرست منبع

pass argument to remote command

Tobias Simetsreiter 2 سال پیش
والد
کامیت
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