Show-installationretartprompt giving an error

My script has been working well, up until the part where it executes the below code.

Show-InstallationRestartPrompt -Countdownseconds 240 -CountdownNoHideSeconds 30 
		Start-Sleep -Seconds 15 #JIC 
	 	Exit-Script -ExitCode 1641 # 1641 = Hard-Reboot

I get an pop-up error from the Toolkit log below. I’m using an interactive install with Intune, so I’m not sure why “Nosilentrestart” is a needed variable.
The old MSI gets removed correctly and the new updated MSI get installed. Its only this last detail that Im stuck on. I need the prompted reboot to happen as the MSI needs a reboot to finish install. Any help would be great. Thanks

Message        : Cannot process argument transformation on parameter 'NoSilentRestart'. Cannot convert value 
                 "System.String" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, 
                 such as $True, $False, 1 or 0.
InnerException : System.Management.Automation.ArgumentTransformationMetadataException: Cannot convert value 
                 "System.String" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, 
                 such as $True, $False, 1 or 0. ---> System.Management.Automation.PSInvalidCastException: Cannot 
                 convert value "System.String" to type "System.Boolean". Boolean parameters accept only Boolean values 
                 and numbers, such as $True, $False, 1 or 0.
                    at System.Management.Automation.ArgumentTypeConverterAttribute.ThrowPSInvalidBooleanArgumentCastExc
                 eption(Type resultType, Type convertType)
                    at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics 
                 engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet)
                    --- End of inner exception stack trace ---
                    at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics 
                 engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet)
                    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal 
                 parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)

FullyQualifiedErrorId : ParameterArgumentTransformationError,Show-InstallationRestartPrompt
ScriptStackTrace      : at <ScriptBlock>, 
                        C:\WINDOWS\IMECache\99cd0bb1-4609-48d4-a60e-9c13c6a1b2d9_13\Deploy-Application.ps1: line 231
                        at <ScriptBlock>, <No file>: line 1
                        at <ScriptBlock>, <No file>: line 1

PositionMessage : At C:\WINDOWS\IMECache\99cd0bb1-4609-48d4-a60e-9c13c6a1b2d9_13\Deploy-Application.ps1:231 char:84
                  + ... -Countdownseconds 3600 -CountdownNoHideSeconds 30 Start-Sleep -Second ...
                  +                                                                          ~~~~~~~~~~~



Error Inner Exception(s):
-------------------------

Message        : Cannot convert value "System.String" to type "System.Boolean". Boolean parameters accept only Boolean 
                 values and numbers, such as $True, $False, 1 or 0.
InnerException : System.Management.Automation.PSInvalidCastException: Cannot convert value "System.String" to type 
                 "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 
                 or 0.
                    at System.Management.Automation.ArgumentTypeConverterAttribute.ThrowPSInvalidBooleanArgumentCastExc
                 eption(Type resultType, Type convertType)
                    at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics 
                 engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean bindingScriptCmdlet)



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message        : Cannot convert value "System.String" to type "System.Boolean". Boolean parameters accept only Boolean 
                 values and numbers, such as $True, $False, 1 or 0.
InnerException :

I tried your code snippet and it’s working for me:

Show-InstallationRestartPrompt -Countdownseconds 240 -CountdownNoHideSeconds 30

However your error is referencing that you have supplied the -NoSilentRestart command with some string value that cannot be parsed as a boolean. See the example in the built-in help:

Show-InstallationRestartPrompt -Countdownseconds 300 -NoSilentRestart $false -SilentCountdownSeconds 10

Hi,

I did end up getting the restart prompt to work. I will post the code snippet for this but I’m trying to get remove-msiapplications to return it’s exit code into a variable so I can use that variable in a try {} catch{} snippet if the try fails and returns the exit code. Right now the full script ends when the try code returns 1612 because the Msi installer is missing… The catch will take the exit code of 1612 and then try to uninstall based on the Msi file in the Files folder.

I can’t seem to get a new variable to actually store the exit code to be able to pass it on to the catch code. Every time the exit code from remove-msiapplications is 1612, the full pre reinstall script ends and the script exits.

I’ve tried - PassThru, but doesn’t seem to work.

Any help would be appreciate.

The simpler approach would be to just ignore the errors (-ContinueOnError defaults to $true for Remove-MsiApplications), then run Execute-MSI afterwards - it does a check to make sure the MSI is installed first, and it it isn’t, it’ll skip the action.

Note if you’re getting 1612 errors, you might even fail to uninstall with the MSI path supplied - if so, try adding -AddParameters 'REINSTALLMODE=v.

1 Like

I had to add the - parameters reinstallmode=v to get the Msi to uninstall even with specifiyinf the Msi path. The strange part is the shortcut for the version being removed didn’t delete its desktop shortcut, it just went blank instead… even though the application itself was removed,which isn’t ideal for the end user.

I’m also considering using some code that would check the uninstall registry location for the original MSI uninstaller file path and then copy the MSI from the files folder to windows>installer folder and rename to what the registry is expecting. Do you think that would work using PSADT? I just know having the blank desktop shortcut left behind will confuse users.

I appreciate the guidance!

Just reproduced - use REINSTALLMODE=vomus instead (omus is default).

It’s a bit of a hack there using REINSTALLMODE when uninstalling something, so I didn’t realise that the other letters there would have an effect on uninstall!

Another option is to run Execute-Msi -Repair -RepairFromSource $true (this will repair the MSI whilst also including REINSTALLMODE=vomus) before running a standard uninstall command.

You can also modify the sourcelist either in the registry or via the Windows Installer API, but this is a bit more advanced and probably unnecessary when we have this simpler method.

1 Like

So it seems Remove-MSIApplications -Name ‘Forticlient’ -ExcludeFromUninstall @(@(‘DisplayVersion’,‘7.2*’,‘Contains’)) -ContinueOnError $true has stopped continuing on error. The MSI installer file is not being found, but the next line of code is not being executed.

Execute-MSI -Action Uninstall -Path ‘Forticlient6.msi’ -Parameters=‘vomus’