I want to pass some arguments to a script block that will be run on a remote Sitecore instance via SPE remoting. I wrote this script as a test, but it's not working.
$session = New-ScriptSession -ConnectionUri "http://sc81up3" -Username admin -Password b
Invoke-RemoteScript -Session $session -ScriptBlock { param($name) Write-Output "hi $name" } -Arguments @{"name"="Ben"}
Stop-ScriptSession -Session $session
This wasn't my first attempt. I tried, just passing "Ben"
as the Argument
parameter, but that caused an error about not being able to convert a string to a hashtable. When I pass the hashtable as shown above, I don't get an error, but the output is just hi
, so it seems the value isn't getting passed.
What is the correct way to pass arguments to the script block executed by Invoke-RemoteScript?