I am trying to use invoke command to run a .ps1 script that is located on a server to deploy software to a client machine. Here is my code:
$s = new-pssession <computername>
invoke-command -session $s -filepath '<server\folder\folder\folder with space\test.ps1>' -ArgumentList process, service
remove-pssession $s
When I run that script, nothing happens on the remote computer and I receive no error messages on my server. If I try to add credentials I get the following error message:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
*invoke-command -session $s -filepath '<server\folder\folder\folder with space...>
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CatagoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
+ FullyQualifiedErrorID : AmbiguousParameterSet,Microsoft.Powershell.Commands.InvokeCommandCommands
Can anyone provide some help?