Reputation: 834
We have requirement to execute .exe with parameters remotely from Linux machine to Windows 10. So we have installed PowerShell in CentOS. Following are the commands we used:
Invoke-Command -HostName abcdefg -Credential $creds -ScriptBlock { Start-Process -FilePath "C:\sip\GetProcessInstance.exe" -$args[0] } -ArgumentList "http://hostname:8080/jbpm-console/rest/task/[email protected]"
Invoke-Command -HostName abcdefg -Credential $creds -ScriptBlock { Start-Process -FilePath "C:\sip\GetProcessInstance.exe" -ArgumentList "http://hostname:8080/jbpm-console/rest/task/[email protected]" }
Invoke-Command -HostName abcdefg -Credential $creds -ScriptBlock { Get-ChildItem C:\ }
Getting following error
Invoke-Command : Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.
At line:1 char:1
Same is working for Windows to Windows.
Upvotes: 1
Views: 543
Reputation: 5227
As stated in the error message, you are trying to use invalid parameter set. Once you open the documentation for Invoke-Command
you can find sets you can use.
Take a look at the block at the beginning of document I linked. There are only two possible sets with -HostName
parameter:
Invoke-Command
-ScriptBlock <scriptblock>
-HostName <string[]>
[-Port <int>]
[-AsJob][-HideComputerName]
[-UserName <string>]
[-KeyFilePath <string>]
[-SSHTransport]
[-RemoteDebug][-InputObject <psobject>]
[-ArgumentList <Object[]>]
[<CommonParameters>]
Invoke-Command
-FilePath <string>
-HostName <string[]>
[-Port <int>]
[-AsJob]
[-HideComputerName][-UserName <string>]
[-KeyFilePath <string>]
[-SSHTransport]
[-RemoteDebug]
[-InputObject <psobject>][-ArgumentList <Object[]>]
[<CommonParameters>]
As you can see, none of them has -Credential
parameter available. Your options are:
WinRM
instead of SSH
In this case you'll have to use -ComputerName
param instead of -HostName
-SSHConnection
From the docs:
This parameter takes an array of hashtables where each hashtable contains one or more connection parameters needed to establish a Secure Shell (SSH) connection (HostName, Port, UserName, KeyFilePath).
As I don't have knowledge about your configuration I cannot tell you which one will suit you best so you have to choose yourself.
Upvotes: 2