Passing a username to a NuGet post-deployment script

We have an installer which we’ve packaged up into a NuGet package. We deploy the installer onto our target machines and use a post-deployment script to run the installer on each box. The installer needs a username which I’ve been trying to pass as a parameter in a step template, but the post-deployment script doesn’t give me the option to use the $OctopusParameters[‘Username’] parameter (in the ‘Insert a variable’ menu next to the script).

If I use the parameter anyway and try to Write-Output the value of the parameter, I get:

Installing Server Components Using System.Collections.Generic.Dictionary`2[SystInfo 08:38:20

Am I doing something wrong here? Can I use the step parameters in the post-deployment script? If not, how do I pass the username into our deployment?


It looks like the is the variable ignoring the [‘username’] part. A quick and simple solution will be to change from this:

msiexec foo.msi "/username=$OctopusParameters['Username']"


$username = $OctopusParameters['Username']
msiexec foo.msi "/username=$username"

Please let me know how you go and if this resolves your issue.

Hi Vanessa,

Yes, this works as expected. Any ideas why the original code doesn’t work?

Thanks for your help


Hi Chris,

Yeah it’s kinda a Windows fault.
Once the variable is in quotes, with a $ it reads to the end of the word, and disregards the bracketed part.
If you open up a PowerShell ISE and copy and paste both below examples you will see in the first how everything past Parameters is in the same color and ignoring the syntax highlighting.
Whereas when the second is called it isn’t within quotes, and shows the correct highlighting for the brackets.

Fun huh? :wink: