Help with EXE and shut down commands

Hey guys…

We are deploying a bios update for our Lenovo laptops. Obviously that requires a reboot. Lenovo’s documentation says to use the following command:

WINUPTP.exe -s & shutdown /r /t 0

I’m having trouble getting the correct syntax. I thought it would be similar to:

Execute-Process -Path WINUPTP.exe -s & shutdown /r /t 0

but it’s not working. Obviously it’s 2 commands…winuptp.exe and the shutdown commands. Not sure how/where to place them.

Any ideas?

Lenovo does not know or care that you are using PowerShell + PSADT.
Here Lenovo assumes everybody knows CMD or BAT file and are one-liner experts.
Your ONE line is actually 2 commands linked with a conditional operator &.

Translating WINUPTP.exe -s to PowerShell + PSADT you get:

Execute-Process -Path “WINUPTP.exe” -Parameters “-s” -ContinueOnError $False

This will only work if you have WINUPTP.exe in the \Files\ folder. (PSADT will look in \Files\ folder by default)

You don’t need to use shutdown.exe /r /t 0 because PSADT has it’s own way to reboot the computer. Look in PSAppDeployToolkit.pdf for Show-InstallationRestartPrompt

Show-InstallationRestartPrompt -Countdownseconds 61 -CountdownNoHideSeconds 60

NOTE: Native PowerShell also has it’s own way of restarting the computer but if you use it, the computer will probably reboot before PSADT finishes.

Good Luck

2 Likes

So this command worked:

Execute-Process -Path “WINUPTP.exe” -Parameters “-s” -ContinueOnError $False

But script failed to restart the computer with the following errors:

[Installation] :: Executing [C:\Windows\ccmcache\2k\Files\WINUPTP.EXE -s]… Execute-Process 7/16/2021 2:18:04 PM 16032 (0x3EA0)
[Installation] :: Execution failed with exit code [1]. Execute-Process 7/16/2021 2:18:27 PM 16032 (0x3EA0)
[Installation] :: Closing the installation progress dialog. Close-InstallationProgress 7/16/2021 2:18:27 PM 16032 (0x3EA0)
[Installation] :: Closing the installation progress dialog’s runspace. Close-InstallationProgress 7/16/2021 2:18:27 PM 16032 (0x3EA0)
[Installation] :: LenovoLaptopBiosUpdate Installation completed with exit code [1]. Exit-Script 7/16/2021 2:18:27 PM 16032 (0x3EA0)

Based on that logging, it does not appear you implemented the “Show-InstallationRestartPrompt” part but here is what I have done with success in the past with HP BIOS updates.

This is more manual but I am not blindly forcing BIOS updates on systems that do not need it.

First I get the BIOS version and model of the computer:

$BIOSVersion = (Get-WmiObject -Class Win32_BIOS).SMBIOSBIOSVersion
$ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem | Select-Object Manufacturer, Model

Then I run a big switch statement that checks the BIOS version and if the current BIOS version is older, install the new one and prompt for reboot.

Switch ($ComputerInfo.Model) {

    "HP EliteBook 820 G3" {
        If ($BIOSVersion -ge [version]"01.33") {
            #BIOS up to date.
        } else {
            #Update BIOS and prompt for reboot
        }
    }

    "HP EliteBook 820 G4" {
        If ($BIOSVersion -ge [version]"01.23") {
            #BIOS up to date.
        } else {
            #Update BIOS and prompt for reboot
        }
    }
}

I found WINUPTP exit codes on this blog, I doubt they changed much over the years: Return codes for WINUPTP

So with that, you should be able to do something like this:

$BIOSUpdate = Execute-Process -Path "WINUPTP.exe" -Parameters "-s" -PassThru -WaitForMsiExec

If($BIOSUpdate.ExitCode -eq 1) {
    #Show reboot dialog
}
1 Like

Thanks! Couple things…

  1. I used the -IgnoreExitCodes option and got it past the exit code 1 point of failure.

  2. I then get prompted with the dialog window from these lines:

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 } 

I then click OK but nothing happens.

  1. I do have the "Show-InstallationRestartPrompt” command in the script, but as you mentioned, it’s not working. I have it in the post install section. Is that not where it goes?
  ## <Perform Post-Installation tasks here>
    Show-InstallationRestartPrompt -Countdownseconds 61 -CountdownNoHideSeconds 60 

I also see this feedback in the script, but I never see the countdown and it never restarts

[07-17-2021 19:52:51.463] [Post-Installation] [Show-InstallationRestartPrompt] :: Invoking Show-InstallationRestartPrompt asynchronously with a [61] second countdown…

…but I never see the countdown and it never restarts

Check the log file and make sure it says something like this:
[06-01-2020 09:57:24.551] [Initialization] [PSADT] [Info] :: Installation is running in [Interactive] mode.

no interactive, no countdown GUI.
BTW: The log file is your eyes. Make it work for you when you write your install scripts.

1 Like

Thanks for the tip… Searching the logs yields these three lines, so I don’t know which to believe. I do see the deferment popup dialog window, so that tells me it’s in interactive mode? No?

[Initialization] :: Session 0 detected, process not running in user interactive mode; deployment mode set to [NonInteractive]. PSAppDeployToolkit 7/20/2021 11:45:25 AM 5144 (0x1418)
[Initialization] :: Installation is running in [NonInteractive] mode. PSAppDeployToolkit 7/20/2021 11:45:25 AM 5144 (0x1418)

[Initialization] :: Session 0 detected, process running in user interactive mode, user(s) logged in. PSAppDeployToolkit 7/20/2021 11:53:54 AM 1464 (0x05B8)

The log file you just posted actually say [NonInteractive] so no.

I don’t use deferments but I assume it’s launched by a scheduled task in the user’s context (aka runs as the user). That’s why you can see the deferment popups.

Your actual deployment, however, is running in the SYSTEM context. To make it visible you need to do 2 things:

  1. In SCCM, you have to check the box for “Allow users to view and interact with the program installation” in the Deployment Type → User Experience tab

  2. In the Deployment Type → Programs tab, for the Installation program, you’ll have to add these parameters at the end: Install Interactive