This project is read-only.

Custom Toolkit Parameter

Topics: Archive - Deployment Scripts, Archive - Toolkit Extensions
Mar 19, 2015 at 2:59 AM
I included some detection logic in a deployment script to check for the existence of the installed product before making an attempt to install/uninstall the application. I placed the conditional logic into a function and placed the function in the "AppDeployToolkitExtensions.ps1". The detection logic works flawlessly when the function is called from my "Deploy-Application.ps1." My question is quite simple I would like to create a custom command line parameter that calls the custom Toolkit function if the parameter is used in the command line. For example; it is assumed that the following forces the uninstall to execute Silently (non-interactively) otherwise the default nature is to execute the install routine interactively.
Deploy-Application.ps1 -DeploymentType "Uninstall" -DeployMode "Silent"
I would like to accomplish something similar
Deploy-Application.ps1 -DeploymentType "Uninstall" -DeployMode "Silent" -CustomParam "Yes"
Where the default behavior of "-CustomParam" is set to "No" unless explicitly set to "Yes" at which point would call the custom function in the "AppDeployToolkitExtensions.ps1" to process conditional logic. Any suggestions on how to accomplish this would be greatly appreciated.

Best Regards,

Mar 19, 2015 at 5:46 PM
Hi Yves,

in Deploy-Application.ps1 add following:
Param (
    [string]$CustomParam = 'No',
You can now use the value of $CustomParam.
As a suggestion, maybe implemented as a boolean instead, just like the variable $AllowRebootPassThru.
This way it switches to $true if the parameter is specified even without a value, otherwise it is $false.
Marked as answer by yralexandre on 3/19/2015 at 7:45 PM
Mar 20, 2015 at 6:13 PM
Thank you for the expert advice!

Best Regards,