Will Deploy-Application.exe pass custom parameters?

I’m using PSADT 3.8.4. I have a script to install a printer driver and install a printer. It has some custom parameters -Name -Model -Port. If I run this using Deploy-Application.exe, nothing happens. I’m immediately returned to PS >. If I replace .exe with .ps1, it runs successfully.

I found a post from 2017, Deploy-Application.exe want to use custom parameters. Other offered suggestions that hint that it must be possible, but this has not been my experience.

Immediately after posting, I realized I should have RTFM. The Administrator Guide has a section called Toolkit Parameters which states “The following parameters are accepted by Deploy-Application.ps1.” That language leads me to believe it will NOT pass through my customer parameters.

post your script :innocent: :smiling_face_with_three_hearts:

I have some PSADT scripts with custom parameters. I modified the EXISTING param block of the deploy-application.ps1 file to include the additional parameters. Note that you must get the syntax correct or they don’t work. I suggest you start with something REALLY simple like a single switch and get that working before trying anything more complex. If you post the Param part of your script we might be able to help you more.

For the curious, I stayed out of this thread because I rarely use the Deploy-Application.exe and use the Deploy-Application.PS1 directly from SCCM. If the OP wants help with modifying Deploy-Application.PS1 to add additional parameters, I’m willing to help.

FYI: If you post code, please select the code and use </> in the editor to make it readable.

I can post my code, if I can remember which script it was! LOL. But I’m not looking for someone to fix my script. I just wanted to verify my suspicion that Deploy-Application.exe does NOT pass those along to PowerShell.

Here is my script. I’m interested in $Name, $Model, and $Port:

<#
.SYNOPSIS
	This script performs the installation or uninstallation of an application(s).
	# LICENSE #
	PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
	Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
	This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
	You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
.DESCRIPTION
	The script is provided as a template to perform an install or uninstall of an application(s).
	The script either performs an "Install" deployment type or an "Uninstall" deployment type.
	The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
	The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
.PARAMETER DeploymentType
	The type of deployment to perform. Default is: Install.
.PARAMETER DeployMode
	Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
.PARAMETER AllowRebootPassThru
	Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
.PARAMETER TerminalServerMode
	Changes to "user install mode" and back to "user execute mode" for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
.PARAMETER DisableLogging
	Disables logging to file for the script. Default is: $false.
.EXAMPLE
    powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeployMode 'Silent'; Exit $LastExitCode }"
.EXAMPLE
    powershell.exe -Command "& { & '.\Deploy-Application.ps1' -AllowRebootPassThru; Exit $LastExitCode }"
.EXAMPLE
    powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeploymentType 'Uninstall'; Exit $LastExitCode }"
.EXAMPLE
    Deploy-Application.exe -DeploymentType "Install" -DeployMode "Silent"
.NOTES
	Toolkit Exit Code Ranges:
	60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
	69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
    60200 - User cancel @ IP Address input
	70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1

	3.8.4 Template (2021-05-27)
		Deploy-Applications.ps1
			Feature Updates
				N/A
			Bus Fixes
				- Changes If startement for Install to use -in so that other deployment types can be 
				  added easily.  # If ($deploymentType -in 'Install')
				- The same change was made in the If statement for Repair, although that will probably 
				  never matter.  Uniformity ;)
    3.8.4 Template (2021-05-24)
        Deploy-Application.ps1
            Feature Updates
                - Removed DeploymentTypes Rollback and Update.
				- Uninstall no longer runs as part of a installation.
            Bug Fixes
                N/A
        AppDeployToolkitExtensions.ps1
            Feature Updates
                N/A
            Bug Fixes
                - Remove-Shortcut 2.2.0
					- Resolves an issue where the public user account's start menu was not getting scanned for .LNK files because 
					  the start menu is stored in a completely different path.
        AppDeployToolkitConfig.xml
            Feature Updates
                N/A
            Bug Fixes
                N/A
.LINK
	http://psappdeploytoolkit.com
#>
[CmdletBinding()]
Param (
	[Parameter(Mandatory=$false)]
	[ValidateSet('Install','Uninstall')] ## BiffCo Customization
	[string]$DeploymentType = 'Install',
	
    [Parameter(Mandatory=$false)]
	[ValidateSet('Interactive','Silent','NonInteractive')]
	[string]$DeployMode = 'NonInteractive', ## BiffCo Customization

	[Parameter(Mandatory=$false)]
	[switch]$AllowRebootPassThru = $false,
	
    [Parameter(Mandatory=$false)]
	[switch]$TerminalServerMode = $false,
	
    [Parameter(Mandatory=$false)]
	[switch]$DisableLogging = $false,
    
	## BiffCo Customization Start
	[Parameter(Mandatory=$False)]
    [string]$Name='MLP Printer',

    [Parameter(Mandatory=$False)]
    [string]$Model='Printronix Auto ID T4M (203 dpi) - PGL',

    [Parameter(Mandatory=$False)]
    [string]$Port=$Null,
        
    [Parameter(Mandatory=$False)]
	[ValidateSet('MachinePolicy', `
				 'DiscoveryData', `
				 'ComplianceEvaluation', `
				 'AppDeployment', `
				 'HardwareInventory', `
				 'UpdateDeployment', `
				 'UpdateScan', `
				 'SoftwareInventory')]
	[string]$CMAction,
    
    [Parameter(Mandatory=$False)]
    [switch]$RebootRequired
    ##BiffCo Customization End
)

Try {
	## Set the script execution policy for this process
	Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}

	##*===============================================
	##* VARIABLE DECLARATION
	##*===============================================
	## Variables: Application
	[string]$appVendor = 'Seagull Scientific'
	[string]$appName = 'Printronix AutoID Printer Driver'
	[string]$appVersion = '2021.2'
	[string]$appArch = ''
	[string]$appLang = 'EN'
	[string]$appRevision = '01'
	[string]$appScriptVersion = '1.0.0'
	[string]$appScriptDate = '2021-11-18'
	[string]$appScriptAuthor = 'John Trask'
	##*===============================================
	## Variables: Install Titles (Only set here to override defaults set by the toolkit)
	[string]$installName = ''
	[string]$installTitle = ''

	##* Do not modify section below
	#region DoNotModify

	## Variables: Exit Code
	[int32]$mainExitCode = 0

	## Variables: Script
	[string]$deployAppScriptFriendlyName = 'Deploy Application'
	[version]$deployAppScriptVersion = [version]'3.8.4'
	[string]$deployAppScriptDate = '26/01/2021'
	[hashtable]$deployAppScriptParameters = $psBoundParameters

	## Variables: Environment
	If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
	[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

	## Dot source the required App Deploy Toolkit Functions
	Try {
		[string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
		If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
		If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
	}
	Catch {
		If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
		Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
		## Exit the script, returning the exit code to SCCM
		If (Test-Path -LiteralPath 'variable:HostInvocation') { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
	}

	#endregion
	##* Do not modify section above

	## BiffCo Variables - Put any variables that might be needed for mulitple deployment types here.
    ## $LogFile = "$($LogFile.BaseName) ($envUsername).$($LogFile.Extension)"  ## BiffCo template field ## Totally untested.
	
	## This is a couple of random strings that should never exists as processes.
	$CloseApps = 'fnjup5799HGfg, NKPnonUN8HBG' ## BiffCo template field

	##*===============================================
	##* END VARIABLE DECLARATION
	##*===============================================
    
    If ($deploymentType -in 'Uninstall') { ## BiffCo Customization
		##*===============================================
		##* PRE-UNINSTALLATION
		##*===============================================
		[string]$installPhase = 'Pre-Uninstallation'

		## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
		#Show-InstallationWelcome -CloseApps $CloseApps -CloseAppsCountdown 60 ## BiffCo Customization

		## Show Progress Message (with the default message)
		#Show-InstallationProgress

		## <Perform Pre-Uninstallation tasks here>


		##*===============================================
		##* UNINSTALLATION
		##*===============================================
		[string]$installPhase = 'Uninstallation'

        Execute-Process -Path "$dirFiles\Install\DriverWizard.exe" -Parameters "remove /driver:`"$Model`""

		##*===============================================
		##* POST-UNINSTALLATION
		##*===============================================
		[string]$installPhase = 'Post-Uninstallation'

		## Remove-Shortcut -Name 'Flight Simulator' -TargetPath "$envProgramFilesx86\Flying Boat Software\FlightSim 2020" -TargetFile 'FlightSim2020.exe' ## BiffCo example
		## Remove-Shortcut -Name 'Flight Simulator' ## BiffCo example
		## Remove-Shortcut -TargetFile 'FlightSim*' ## BiffCo example
		## Remove-Shortcut -TargetPath "$envProgramFilesx86\Flying Boat Software\*" ## BiffCo example
		# Remove-Shortcut -TargetPath "$envProgramFiles\$appVendor\AppName*" ## BiffCo template field

		## Remove-RegistryKey -Key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$AppName" ## BiffCo example
		#Remove-RegistryKey -Key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$AppName"  ## BiffCo template field
	}
	
    If ($deploymentType -in 'Install') { ## BiffCo Customization
		##*===============================================
		##* PRE-INSTALLATION
		##*===============================================
		[string]$installPhase = 'Pre-Installation'

		## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
		Show-InstallationWelcome -CloseApps $CloseApps -CheckDiskSpace -PersistPrompt ## BiffCo Customization

		## Show Progress Message (with the default message)
		Show-InstallationProgress

        Import-Certificate -FilePath "$dirFiles\Install\Seagull_2021.08.02.cer" -CertStoreLocation "Cert:\LocalMachine\TrustedPublisher"
 
        $IsValidPort = $False
        While ($IsValidPort -eq $False) {
            $Port = [Microsoft.VisualBasic.Interaction]::InputBox("Please enter the IP address of the printer.","IP Address")
            Write-Host $Port.Length
            If (($Port.Length -eq 0) -or ($Null -eq $Port)) {
                Exit-Script -ExitCode 69200
            }

            Try {
                $Port = [IPAddress]$Port
                $IsValidPort = $True
            } Catch {
                #Write-Host "`$Port [$Port] is invalid" -ForegroundColor Red
                $Output = [Microsoft.VisualBasic.Interaction]::MsgBox("[$Port] is NOT a valid IP Address.","OKCancel,SystemModal,Critical","Invalid IP Address")
                $IsValidPort = $False
                If ($Output -eq 'Cancel') {
                    Exit-Script -ExitCode 69200
                }
            }
        }

        Try {
            $PPort = Get-PrinterPort -Name $Port -ErrorAction Stop
        } Catch {
        
        }
        If ($PPort) {
            Get-Printer | Where-Object {$_.PortName -eq $Port} | Remove-Printer
            $PPort | Remove-PrinterPort
        }

        Add-PrinterPort -Name $Port -PrinterHostAddress $Port
        
		##*===============================================
		##* INSTALLATION
		##*===============================================
		[string]$installPhase = 'Installation'

        Execute-Process -Path "$dirFiles\Install\DriverWizard.exe" -Parameters "install /name:`"$Name`" /model:`"$Model`" /port:`"$Port`""

		##*===============================================
		##* POST-INSTALLATION
		##*===============================================
		[string]$installPhase = 'Post-Installation'

		## Add-AddRemoveProgram -DisplayName $appName -SystemComponent ## BiffCo example
		## Add-AddRemoveProgram -DisplayName $appname -DisplayVersion $appVersion -SystemComponent ## BiffCo example
		## !!!Myriad problems could arise by including an UninstallString.  You had better be certain!!!
		## Add-AddRemoveProgram -DisplayName $appName -UninstallString 'C:\Program Files (x86)\AFAB Software\Uninstall.exe /s' ## BiffCo example
		## Add-AddRemoveProgram -Displayname $appName -Publisher $appVendor -DisplayVersion $appVersion ## BiffCo example
		## Add-AddRemoveProgram -DisplayName "$appVendor $appName $appVersion" -Displayname $appName -Publisher $appVendor -DisplayVersion $appVersion ## BiffCo example
		## To create a fully armed and operational Add/Remove Programs entry:
		#Add-AddRemoveProgram -Displayname $appName -Publisher $appVendor -DisplayVersion $appVersion -UninstallString <uninstallstring> ## BiffCo template field.
		## To create an entry that will allow the app to be inventoried without showing up in Add/Remove Programs:
		#Add-AddRemoveProgram -DisplayName $appName -Publisher $appVendor -DisplayVersion $appVersion -SystemComponent ## BiffCo template field

		## Display a message at the end of the install
		#If (-not $useDefaultMsi) { Show-InstallationPrompt -Message 'You can customize text to appear at the end of an install or remove it completely for unattended installations.' -ButtonRightText 'OK' -Icon Information -NoWait }
	}

    If ($deploymentType -in 'Repair') { ## BiffCo Customization
		##*===============================================
		##* PRE-REPAIR
		##*===============================================
		[string]$installPhase = 'Pre-Repair'

		## Show Progress Message (with the default message)
		Show-InstallationProgress

		## <Perform Pre-Repair tasks here>

		##*===============================================
		##* REPAIR
		##*===============================================
		[string]$installPhase = 'Repair'

		## Handle Zero-Config MSI Repairs
		If ($useDefaultMsi) {
			[hashtable]$ExecuteDefaultMSISplat =  @{ Action = 'Repair'; Path = $defaultMsiFile; }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
			Execute-MSI @ExecuteDefaultMSISplat
		} Else { ## BiffCo Customization (entire Else section)
            #[string]$BiffRepairMsiFile = "$dirFiles\Install\Widget30.msi"  ## BiffCo template field
            #[string]$BiffRepairMstFile = "$dirFiles\Install\Widget30.mst"  ## BiffCo template field
            #[string]$BiffRepairMsiParam = "/qn SERVERNAME=wdxxxxxx"  ## BiffCo template field
            #[string]$BiffRepairMsiAddParam = "SERVERNAME=wdxxxxxx"  ## BiffCo template field
            If ($BiffRepairMsiFile) {
                [hashtable]$BiffRepairMsiSplat =  @{ Action = 'Repair'; Path = $BiffRepairMsiFile }
                If ($BiffRepairMsiTransform) { $BiffRepairMsiSplat.Add('Transform', $BiffRepairMsiTransform) }
                If ($BiffRepairMsiParam) {$BiffRepairMsiSplat.Add('Parameters',$BiffRepairMsiParam)}
                If ($BiffRepairMsiAddParam) {$BiffRepairMsiSplat.Add('AddParameters',$BiffRepairMsiAddParam)}
			    Execute-MSI @BiffRepairMsiSplat
				If ($BiffInstallMsiPatch) {$BiffInstallMsiPatch | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ }}
            } 
            Remove-Variable -Name 'BiffRepairMsi*'

            #[string]$BiffInstallExeFile = "$dirFiles\Install\Setup.exe"  ## BiffCo template field
            #[string]$BiffInstallExeParam = "/SERVER:wdxxxxxx /Silent"  ## BiffCo template field
            If ($BiffRepairExeFile) {
                [hashtable]$BiffRepairExeSplat = @{Path = $BiffRepairExeFile}
                If ($BiffRepairExeParam) {$BiffRepairExeSplat.Add('Parameters',$BiffRepairExeParam)}
                Execute-Process @BiffRepairExeSplat
            }
            Remove-Variable -Name 'BiffRepairExe*'
        }
	
		##*===============================================
		##* POST-REPAIR
		##*===============================================
		[string]$installPhase = 'Post-Repair'

		## <Perform Post-Repair tasks here>

    }

    ##*===============================================
	##* CMACTION
	##*===============================================
    [string]$installPhase = 'CMAction'
    If ($CMAction) { ## BiffCo Customization (entire If section)
        Try { 
            $ScheduleIDMappings = @{ 
                'MachinePolicy' = '{00000000-0000-0000-0000-000000000021}'; 
                'DiscoveryData' = '{00000000-0000-0000-0000-000000000003}'; 
                'ComplianceEvaluation' = '{00000000-0000-0000-0000-000000000071}'; 
                'AppDeployment' = '{00000000-0000-0000-0000-000000000121}'; 
                'HardwareInventory' = '{00000000-0000-0000-0000-000000000001}'; 
                'UpdateDeployment' = '{00000000-0000-0000-0000-000000000108}'; 
                'UpdateScan' = '{00000000-0000-0000-0000-000000000113}'; 
                'SoftwareInventory' = '{00000000-0000-0000-0000-000000000002}'; 
            } 
            $ScheduleID = $ScheduleIDMappings[$CMAction] 
        } Catch { 
            Write-Error $_.Exception.Message 
        }
        Try {
            Invoke-CimMethod -Namespace 'root\CCM' -ClassName 'SMS_Client' -MethodName 'TriggerSchedule' -Arguments @{sScheduleID = $ScheduleID} | Out-Null
            Start-Sleep 120
        }
        Catch {
            Write-Log 'Failed to invoke CMAction' -Severity 3
            Exit-Script -ExitCode 69500
        } 
	}
	
	##*===============================================
	##* REBOOTREQUIRED
	##*===============================================
    [string]$installPhase = 'RebootRequired'
    If ($RebootRequired) { ## BiffCo Customization (Entire If section)
        Set-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'
	}

	##*===============================================
	##* END SCRIPT BODY
	##*===============================================
    [string]$installPhase = 'EndScript'
	## Call the Exit-Script function to perform final cleanup operations
	Exit-Script -ExitCode $mainExitCode
}
Catch {
	[int32]$mainExitCode = 60001
	[string]$mainErrorMessage = "$(Resolve-Error)"
	Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
	Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
	Exit-Script -ExitCode $mainExitCode
}

I was not expecting the entire script, BTW.

This is the change I would make:

    [Parameter(Mandatory=$False)]
    [string]$Port,

Not every Parameter needs a default.
Unused Parameter / variables are $null if not set
Setting variable to $null sometimes causes weird things to happen.

I don’t know why you want a $port parameter to begin with since you always ask the user for it.
I didn’t find code to detect if $port was set by parameter or not like this:

If ($port) {
	#do stuff
} Else {
	#prompt for $port
}

Otherwise the Param( ) section looks good.

Thanks. This all works if I run the .PS1 directly. It’s just when I use the .EXE. That tells me that it doesn’t just blindly pass along everything it’s been passed.

I have the port parameter on the .000001% chance that someone wants to and/or is able to add it to a command line.

Please post the line you use to launch the EXE.

OK. Before I share this, I want to make it perfectly clear that this was NOT my idea, and that the techs should learn to use the Deploy-Application.exe wrapper.

I launch the .exe from a batch file (yes, a batch file launches the .exe which in turn launches PowerShell) . I don’t use this any more for this application, because I’ve switched to calling the .ps1 directly, but when I tried the batch file did this:

@echo off
“%~dp0Deploy-Application.exe” -DeploymentType Install -DeployMode Noninteractive -Name ‘MX Printer’ -Model ‘Printronix Auto ID T4M (203 dpi) - PGL’

This is a reported bug in Deploy-Application.exe.

Maybe try a PREVIOUS version of Deploy-Application.exe

Personally, I would just delete the Deploy-Application.exe to force the techs to right-click on the CMD like we do for manual installs.

FYI: If you post code, please select the code and use </> in the editor to make it readable.