Created
November 23, 2022 20:33
-
-
Save steviecoaster/ef0bafbb8fcf184bd75646239335eb65 to your computer and use it in GitHub Desktop.
Package parameters example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = 'Stop' | |
$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition | |
#Receive the package parameters from a package as a hashtable | |
#Example: choco install bob -y --package-parameters="'/Server=someserver /User=Bob /Enable'" | |
$pp = Get-PackageParameters | |
#You can then access the hashtable using any method you would normally use, both of the following will retrieve the value for the specified key. | |
$Server = $pp['Server'] #index of key | |
$User = $pp.User #key property | |
#Parameters with no input are treated like a Boolean. Passing it equates to $true, not passing it equates to false | |
$Enabled = $pp['Enable'] #This will evaluate to $true since '/Enable' was passed as a package parameter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment