Author Posts

May 12, 2017 at 9:38 am


I'm trying to pass either an array or hash into Powershell from; I'm constrained on the way it is called based on how it's hardcoded into the PowershellTask. I need to basically make this work when executed from cmd or ccnet.

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -NoProfile -NonInteractive -file "C:\Test\Input.ps1" -Environment test -Overrides @{'asd'='net';'arguments'='broken'}

In the script I've got:

    [Hashtable]$Overrides = @{}

When I try that command (through CMD or I get:

 : Cannot process argument transformation on parameter 'Overrides'. Cannot convert the "@{'asd'='net';'arguments'='broken'}" value of type "System.String" to type "System.Collections.Hashtable".

If I switch from -File to -Command it works. Unfortunately the -File is hardcoded in CCNet so I can't change it.

I don't understand why it doesn't work, and why the behaviour is different between -File and -Command.

Is what I want even possible?


May 12, 2017 at 3:13 pm

Thanks for your post. Please try the following:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -Command "& C:\Test\Input.ps1 -Environment test -Overrides @{'asd'='net';'arguments'='broken'}"

I hope that helps.

– Daniel

May 12, 2017 at 4:20 pm

Hi Daniel,

Thank you for your reply. However as I said in my question:

Unfortunately the -File is hardcoded in CCNet so I can't change it.

So, I need it to work with -File not -Command


May 21, 2017 at 7:57 pm


I've been trying more and more things to do this.

I have a feeling it's impossible to pass anything but simple strings into a

powershell -File

execution, can someone confirm? Unfortunately I can't change the execution from -File to -Command as it's hard-coded in 🙁


May 22, 2017 at 7:56 am

Afaik this is true
but you can write a "proxy"

    #[Hashtable]$Overrides = @{}
	[string]$Overrides = ''

"Environment: $Environment"
$Overrides1 = & ([ScriptBlock]::Create($Overrides))
#here you can call your needed file with transformed parameters