Hi.
I have a script1 that has an array of strings as one of the parameters:
[Parameter(Mandatory=$True)]
[string]$RDSL
When script1 is called and I supply it 2 (or more) strings, it works fine, but we call script1 from another script2.
In this script 2, it’s defined/called like this:
[Parameter(Mandatory=$False)]
[string]$RDSL = @(“server1”,“server2”)
…
Execute-Script -Command 'powershell.exe -NonInteractive -NoProfile -File “\unc_path\Script1.ps1” -RDSL $RDSL
When executed like this, the script gets executed, but it parses the array as simple string (it seems) ‘server1 server2’ and the command that expects the array fails.
Sorry, missed the reply.
These are scripts that automate server deployment and configuration. There’s one master script that has parameters that are parsed to individual scripts using the Execute-Script function that executes scripts and checks exit values (defined in the individual scripts).
...
[string[]]$RDSL,
[Parameter(Mandatory=$True)]
...
Set-RDLicenseConfiguration -ConnectionBroker $ComputerFQDN -LicenseServer $RDSL -Mode PerUser -Force
#the above cmd then fails with the problem I described - from logging it seems it's flattened to string 'server1 server2'
I’ve fixed the script by defining the ‘array’ as simple string (separated by comma) in the master script and then converting it to an array in script2.