title: How can I pass multi args with Invoke-Command
body: <p>I want create a few shortcuts on my desktop, it works locally. But when I try it on a remote PC I got only one shortcut for the first target (<code>path1</code>), and script ignores <code>path2</code> variable.</p>
  
  <pre><code>$Servers = Get-Content D:\1.txt
  
  function add-sc {
      param ([string[]]$Targets) 
      BEGIN {}
      PROCESS {
          foreach ($a in $Targets) {
              $WshShell = New-Object -comObject WScript.Shell
              $b = $a.Substring($a.length - 5)
              $Shortcut = $WshShell.CreateShortcut("$Home\Desktop\$b.lnk")
              $Shortcut.TargetPath = $a
              $Shortcut.Save()
          }
      }
      END {}
  }
  
  foreach ($server in $Servers) {
      Invoke-Command -ComputerName $server -ScriptBlock ${function:add-sc} -Args "path1", "path2"
  }
  </code></pre>