Issue with passthrough parameter in SCCM

//Issue with passthrough parameter in SCCM
Issue with passthrough parameter in SCCM2017-01-31T16:31:31+00:00

The Toolkit Forums General Issue with passthrough parameter in SCCM

  • Author
  • Dan
    Post count: 13

    Whenever I add either of these two lines to the Installation program in SCCM, the application fails. Removing them, the application installs fine. SCCM is not liking the syntax of my command line. I really need to pass a 3010 code back to sccm for a restart.

    Install: PowerShell.exe -Executionpolicy bypass .\Deploy-Application.ps1 -DeploymentType “Install” -DeployMode “Silent” -AllowRebootPassThru $true

    Install: Deploy-Application.exe -DeploymentType “Install” -DeployMode “Silent” -AllowRebootPassThru $True

    Any ideas?

  • mikebriggs1973
    Post count: 2

    can you just set the exit code at the end to 3010?

    Exit-Script -ExitCode 3010 #$mainExitCode

  • Dan
    Post count: 13

    Will that passthru to SCCM though?

  • Dan
    Post count: 13

    I asked the same question on Reddit. Here is the answer I got. (Thank you reddit user work-work-work-work)

    Check how [Switch] works as a parameter

    It has one Property “IsPresent” which is a bool.

    By specifying the parameter itself it switches to True, as the parameter was present. (Mostly. The Switch should default to False without having to specify it explicitly)
    TypeName: System.Management.Automation.SwitchParameter

    Name MemberType Definition
    —- ———- ———-
    Equals Method bool Equals(System.Object obj)
    GetHashCode Method int GetHashCode()
    GetType Method type GetType()
    ToBool Method bool ToBool()
    ToString Method string ToString()
    IsPresent Property bool IsPresent {get;}

    Dirty example:
    [Switch]$Interactive = $false


    If($Interactive){write-host “woo”}

    PS C:\temp> .\switchtest.ps1
    PS C:\temp> .\switchtest.ps1 -Interactive
    PS C:\temp>

    • Matt
      Post count: 11


      I use the following which works for me and is not as long or complicated as above:
      “Deploy-Application.exe” -deploymode silent -AllowRebootPassThru

      The code in-line that does passthru to SCCM is as follows:
      $RC = Execute-Process -Path “blahblah” -Parameters “blahblah” -WindowStyle ‘Hidden’ -IgnoreExitCodes “3” -PassThru
      if ($RC.ExitCode -eq “3”) {
      Exit-Script -ExitCode 3010

      You use ignoreexistcode here so that 3 doesn’t trigger AppDeploy to report a failure but you also use the passthru to send it forward. At some point, you still have to tell the script to exit and return that code so in my case, I chose to convert it in-line to a 3010 rather than add it to the app object in SCCM.

  • Dan
    Post count: 13

    So, I’ve got the script to exit with 3010, but it’s still not passing it to SCCM

    Here is my installation program line: PowerShell.exe -Executionpolicy bypass .\Deploy-Application.ps1 -DeploymentType “Install” -DeployMode “Silent” -AllowRebootPassThru

    The exit line in the log is:
    [Post-Installation] :: A restart has been flagged as required.
    [Post-Installation] :: NetMotionWireless,Inc._NetMotionMobilityClient_11.04.22344_x64_EN_01 Installation completed with exit code [3010].

    But I get a failed error in Software Center of 0x1(1). The application installed fine. When I restart, the detection method kicks in and the app shows installed.

    My guess is it is not passing the 3010 exit code to SCCM, thus prompting for a restart, thus completing the installation.

    Any more thoughts?

  • Pelle
    Post count: 100

    Try: PowerShell.exe -Executionpolicy bypass .\Deploy-Application.ps1 -DeploymentType “Install” -DeployMode “Silent” -AllowRebootPassThru:$true

    Alternatively you can change the default value of the parameter AllowRebootPassthru (fram false to true) inside deploy-application.ps1 (I’ve done so in my “template”).

You must be logged in to reply to this topic.