Use a custom parameter

Hello,

I want to add a optional parameter to my ADT package.

It should work like that:
Deploy-Application.exe -configonly

So my custom parameter is called configonly and the user can add the parameter if he needs it.

I added the parameter to the Param block of Deploy-Application.ps1 :

[CmdletBinding()]
Param (
[Parameter(Mandatory=$false)]
[ValidateSet(‘Install’,‘Uninstall’,‘Repair’)]
[string]$DeploymentType = ‘Install’,
[Parameter(Mandatory=$false)]
[ValidateSet(‘Interactive’,‘Silent’,‘NonInteractive’)]
[string]$DeployMode = ‘Interactive’,
[Parameter(Mandatory=$false)]
[switch]$AllowRebootPassThru = $false,
[Parameter(Mandatory=$false)]
[switch]$TerminalServerMode = $false,
[Parameter(Mandatory=$false)]
[switch]$DisableLogging = $false,
Parameter]
[string]$ConfigOnly
)

And if the user uses this parameter, I want to do X. So I I also added in the Pre-Install:
If ($PSBoundParameters.ContainsKey(“ConfigOnly”) {action x}

But that does not work. Do I have to add the parameter to AppEployToolkitMain.ps1?
What am I doing wrong?

Thanks!

Try :
[Switch]$ConfigOnly

If you use -ConfigOnly in the commandline then $ConfigOnly will be $true

And to use the parameter:
If ($ConfigOnly) {action x}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.