Show-ADTInstallationPrompt Error 60001

Show-ADTInstallationPrompt
Great Job, I’ll switch from 3.8.4 to 4.0.5

But why is Show-ADTInstallationPrompt not the same as Show-InstallationPrompt or have an -IgnoreExitCodes
Show-InstallationPrompt could always be used no matter what setting was used

I install via SCCM in the task sequence in provisioning mode, where no user dialog is needed, but I have many packages that are distributed during operation, ie. the user can be logged in. So I always have both options (with and without user) and “User Experience” active in the SCCM

When I use yours, I get error 60001

[Post-Install] :: Bypassing Show-ADTDialogBox [Mode: NonInteractive]. Text: Error Record:
  -------------
   Message               : Die Variable "$MyMessage" kann nicht abgerufen werden, weil sie nicht festgelegt wurde.
   FullyQualifiedErrorId : VariableIsUndefined
  ScriptStackTrace      : bei Install-ADTDeployment, C:\Windows\ccmcache\5\Invoke-AppDeployToolkit.ps1: Zeile 388
                        bei <ScriptBlock>, C:\Windows\ccmcache\5\Invoke-AppDeployToolkit.ps1: Zeile 555
   PositionMessage       : In C:\Windows\ccmcache\5\Invoke-AppDeployToolkit.ps1:388 Zeichen:45
                        +         **Show-ADTInstallationPrompt** -Message $MyMessage -ButtonRightTe ...
                        +                                             ~~~~~~~~~~
[Finalization] :: [900110-Dell-Latitude-7400-Bios1.37.0EN1.0] install completed with exit code **[60001]**.	Close-ADTSession

Your:

   if (!$adtSession.UseDefaultMsi)
    {
        Show-ADTInstallationPrompt -Message $MyMessage -ButtonRightText 'OK' -Icon Information -NoWait

    }

My:

    $MyUser=(Get-ADTRunAsActiveUser).Username
    Write-ADTLogEntry -Message "angemelderter User: $MyUser"
    if ($MyUser) 
      {
        if (!$adtSession.UseDefaultMsi)
        {
          Show-ADTInstallationPrompt -Message $MyMessage -ButtonRightText 'OK' -Icon Information -NoWait
        }
      }

I watched your webinar

How can I prevent, ignore, suppress errors?
Show-ADTInstallationPrompt -Message $MyMessage -ButtonRightText 'OK' -Icon Information -NoWait -ErrorAction Ignore
-ErrorAction Ignore or -ErrorAction SilentlyContinue is that possible
$LastExitcode - Powershell - the same in PSADT ?
$Error.Clear() is that possible?

I don’t know German but I think it says $MyMessage is not defined.

V3 wouldn’t care but V4 way more picky.

We enable strict mode at v1 levels by default in Invoke-AppDeployToolkit.ps1 because PowerShell has always been stupidly loose and this is one example. If it was off, you’d get the dialog up with an empty message, which is decidedly worse than the call to the function failing because you’ve got a non-existent variable.

Define $MyMessage with whatever message you want and the problem will resolve itself.

1 Like

Thanks, no, I assigned the text in the variable before catching it with (Get-ADTRunAsActiveUser).Username / if ($MyUser).

# nur Deutsch
if ($MyLanguage -like "de-DE"  ) 
    {
    Write-ADTLogEntry -Message "nur Deutsch"
    $MyMessage="Bitte Neustart ausführen - ca. 2-3 Neustarts bis es zur Anmeldung kommt - !!!! nicht ausschalten !!!!!"
    }

# nur French
if ($MyLanguage -like "fr-Fr" ) 
    {
    Write-ADTLogEntry -Message "nur Französisch"
    $MyMessage="Veuillez redémarrer - environ 2-3 redémarrages jusqu'à l'enregistrement - !!!! ne pas éteindre !!!!!"
    }

$MyUser=(Get-ADTRunAsActiveUser).Username
Write-ADTLogEntry -Message "angemelderter User: $MyUser"
if ($MyUser) 
  {
    if (!$adtSession.UseDefaultMsi)
    {
      # Show-ADTInstallationPrompt -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
      Show-ADTInstallationPrompt -Message $MyMessage -ButtonRightText 'OK' -Icon Information -NoWait
    }
  }

The problem with your setup is there’s the potential for $MyMessage to have never been defined at all if a language other than German or French is used.

You can either declare the variable before your branches, such as $MyMessage = $null or change all this out to a switch case setup, where there’s a default fallback case.

Either way, you should be testing either for the availability of $MyMessage or whether the value of $MyMessage is null because the checks you have are incorrect.

2 Likes

thanks, it doesn’t like null
this:

if ($MyLanguage -notlike "de-DE" -or $MyLanguage -notlike "fr-Fr" ) {$MyMessage="noLanguage"}

or nested:

    $MyUser=(Get-ADTRunAsActiveUser).Username

    if ($MyUser) 
	{
        if (!$adtSession.UseDefaultMsi)
        {
          Show-ADTInstallationPrompt -Message $MyMessage -ButtonRightText 'OK' -Icon Information -NoWait
        }
      }