I have a simple Powershell script which accepts 2 parameters (script1.ps1):
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)][object] $parameter1,
[Parameter(Mandatory=$true)][object] $parameter2
)
Write-Output "executing script...."
From a different script, I load the parameters and call the script above:
$parameters = @{
parameter1 = $parameter1
parameter2 = $parameter2
}
# execute script with parameters
& "./script1.ps1" $parameters
When I run this script which calls script1.ps1 in Debug mode, I always get prompted for parameter2, even though parameter2 contains a value. If I then supply a value at the prompt and then hit the breakpoint in script1.ps1, I can hover over $parameter1, and it contains a collection of both parameters.
How do I do this correctly so that the parameters show up in script1.ps1 in the correct position?