I have the script that works perfectly when run from ISE or VS Code with parameters given in code like
param(
[string]$Param1 = "example",
[string[]]$Param2 = @('arrayparam1','arrayparam2'),
[string[]]$Param3 = @('arrayparam1','arrayparam2'),
[switch]Param4 = $true
)
But whenever I run this script without params in code but with params from console like
.\Script -Param1 example -Param2 'arrayparam1','arrayparam2' -Param3 'arrayparam1','arrayparam2' -Param4
it starts running but it generates empty csv file (with param in code this works perfectly). So I was running this script with "powershell.exe -File" (which generated nice file) like this:
powershell.exe -File .\Script -Param1 example -Param2 'arrayparam1','arrayparam2' -Param3 'arrayparam1','arrayparam2' -Param4
But the problem is that it takes only first item from array. If second array is empty it gives second item from first array to second array as first item (this blew my mind).
My goal is to run this script with all parameters from console without "-powershell.exe -File". I have tried various ExecutionPolicy and now I'm using RemoteSigned. I am using powershell, powershell ISE and VS code to test this but it always works the same. I have tried passing arrays as "1","2", ('1','2'), @("1","2") but it never works.
Please help