Passing Name or Id parameter to my script with Invoke-PSUScript
Product: PowerShell Universal Version: 4.2.14
Just new to PSU and currently testing if it can be a replacement for what i need Azure Automation for atm.
There is one issue though invoking scripts with the cmdlet Invoke-PSUScript. when my script expects the parameter Id or Name, as it fails with:
System.Management.Automation.MetadataException: A parameter with the name ‘Name’ was defined multiple times for the command.
I specified the arguments of myscripts parameter in a hashtable and specified it with parameters parameter:
$Arguments = @{Name='NameValueFromMyScript'; Id=1; AdditionalParam='abc'}
Invoke-PSUScript -Name "MyScript.ps1" -Parameters $Arguments
First i thought that parameters should be the way to call when using a parameter Name, Id or any of the reserved parameter names for Invoke-PSUScript cmdlet. But apparently not. If parameters worked this way i could just use splatting…
Can’t be the first one having this issue, but i couldn’t find an existing topic regarding this
I think you should be using the @Arguments instead of $Agruments in your command:
Invoke-PSUScript -Name "MyScript.ps1" -Parameters @Arguments
EDIT: Sorry, the above is wrong. I was browsing on my phone and didn’t really notice. You are correct, a parameter passed using NAME is kicking back the error.