Passing named arguments to a script using -Argumentlist Tagged: Argumentlist, invoke-command This topic contains 3 replies, has 2 voices, and was last updated by Daniel Krebs 2 years, 11 months ago. Author Posts May 24, 2014 at 10:57 pm #15611 Tulasi MokaParticipant Hi I want to execute a script on a remote machine using Invoke-command. My script file accepts name arguments. Can someone help me how to use the Invoke-command with -Argumentlist and named parameters. Invoke-command -computername localhost -filepath .\sample.ps1 -argumentlist (Need this part) My script file accepts two parameters: .\sample.ps1 -foo "abc" -bar "xyz" Regards, Tulasi Krishna. May 24, 2014 at 11:11 pm #15612 Daniel KrebsParticipant Please check out "Example 11" in the help of Invoke-Command. Get-Help Invoke-Command -Examples It explains how this scenario works and shows the ArgumentList parameter in action. Regards, Daniel May 25, 2014 at 12:03 am #15613 Tulasi MokaParticipant Hi Daniel, The example shows only normal parameters. But my script takes named parameters. How to pass named parameters there? If I try like the below, I get an error Invoke-command -ComputerName localhost -FilePath C:\scripts\Simple1.ps1 -ArgumentList -foo "C:\Temp\a.txt" -bar "C:\Temp\b.txt" Error: Invoke-Command : A positional parameter cannot be found that accepts argument 'C:\Temp\a.txt'. At line:1 char:15 + Invoke-Command <<<< -ComputerName localhost -FilePath C:\scripts\Simple1.ps1 -ArgumentList -foo C:\Temp\a.txt -bar C :\Temp\b.txt + CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand Regards, Tulasi Krishna. May 25, 2014 at 3:37 am #15614 Daniel KrebsParticipant Sorry I didn't read that you want to pass named parameter earlier this morning. Unfortunately Invoke-Command does not support this out of the box. I found a thread on StackOverflow with possible workarounds. http://stackoverflow.com/questions/4225748/how-do-i-pass-named-parameters-with-invoke-command Regards, Daniel Author Posts You must be logged in to reply to this topic.