Parses a string and returns a hash table array of those values for use in package scripts.


Get-PackageParameters `
  [-Parameters <String>] `
  [-IgnoredArguments <Object[]>] [<CommonParameters>]


This looks at a string value and parses it into a hash table array for use in package scripts. By default this will look at $env:ChocolateyPackageParameters (--params="'/ITEM:value'") and $env:ChocolateyPackageParametersSensitive (--package-parameters-sensitive="'/PASSWORD:value'" in commercial editions).

Learn more


Available in 0.10.8+. If you need compatibility with older versions, take a dependency on the chocolatey-core.extension package which also provides this functionality. If you are pushing to the community package repository (, you are required to take a dependency on the core extension until January 2018. How to do this is explained in the docs.

The differences between this and the chocolatey-core.extension package functionality is that the extension function can only do one string at a time and it only looks at $env:ChocolateyPackageParameters by default. It also only supports splitting by :, with this function you can either split by : or =. For compatibility with the core extension, build all docs with /Item:Value.





# The default way of calling, uses `$env:ChocolateyPackageParameters`
# and `$env:ChocolateyPackageParametersSensitive` - this is typically
# how things are passed in from choco.exe
$pp = Get-PackageParameters


# see
# command line call: `choco install <pkg_id> --params "'/LICENSE:value'"`
$pp = Get-PackageParameters
# Read-Host, PromptForChoice, etc are not blocking calls with Chocolatey.
# Chocolatey has a custom PowerShell host that will time these calls
# after 30 seconds, allowing headless operation to continue but offer
# prompts to users to ask questions during installation.
if (!$pp['LICENSE']) { $pp['LICENSE'] = Read-Host 'License key?' }
# set a default if not passed
if (!$pp['LICENSE']) { $pp['LICENSE'] = '1234' }


$pp = Get-PackageParameters
if (!$pp['UserName']) { $pp['UserName'] = "$env:UserName" }
# Requires Chocolatey v0.10.8+ for Read-Host -AsSecureString
if (!$pp['Password']) { $pp['Password'] = Read-Host "Enter password for $($pp['UserName']):" -AsSecureString}
# fail the install/upgrade if not value is not determined
if (!$pp['Password']) { throw "Package needs Password to install, that must be provided in params or in prompt." }


# Pass in your own values
Get-PackageParameters -Parameters "/Shortcut /InstallDir:'c:\program files\xyz' /NoStartup" | set r
if ($r.Shortcut) {... }
Write-Host $r.InstallDir




  • [HashTable]


-Parameters [<String>]

OPTIONAL - Specify a string to parse. If not set, will use $env:ChocolateyPackageParameters and $env:ChocolateyPackageParametersSensitive to parse values from.

Parameters should be passed as "/NAME:value" or "/NAME=value". For compatibility with chocolatey-core.extension, use :.

For example `-Parameters "/ITEM1:value /ITEM2:value with spaces"

:choco-info: NOTE

In 0.10.9+, to maintain compatibility with the prior art of the chocolatey-core.extension method, quotes and apostrophes surrounding parameter values will be removed. When the param is used, those items can be added back if desired, but it's most important to ensure that existing packages are compatible on upgrade.

Property Value
Aliases params
Required? false
Position? 1
Default Value
Accept Pipeline Input? false

-IgnoredArguments [<Object[]>]

Allows splatting with arguments that do not apply and future expansion. Do not use directly.

Property Value
Required? false
Position? named
Default Value
Accept Pipeline Input? false


This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters .

Function Reference

:choco-info: NOTE

This documentation has been automatically generated from Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -Force; Get-Help Get-PackageParameters -Full.

View the source for Get-PackageParameters