Silent install with restart and close processes prompt

Hi all,
I apologize if this has been asked before. I am new to PSADT, so still trying to figure out my way around it. I have been attempting to use the docs and PSADT forums to achieve my desired outcome but having trouble getting all the way there.

I am trying to deploy an update for FortiClient VPN. I would like the behavior to be as follows:

If no user logged in, proceed with install and force reboot
If user logged in, and no selected forticlient processes open, install silently, hide install progress and prompt user for restart
If user logged in, and selected forticlient processes open, prompt user to close processes, show install progress, and prompt user for restart.

I am able to mostly achieve the above, when setting the deploy mode to interactive, but if there are no processes to close, it still shows the installation progress. I would prefer if it just showed the restart prompt. If I set the deploy mode to silent, it doesn't prompt the user if processes are open, and it doesn't prompt for restart. Perhaps I just have to accept showing the install progress, when no processes to be closed?

If the above behavior isn't possible, or there are other ways to achieve a similar outcome, I am happy to try it.

Below are the sections I have edited in the Invoke-AppDeployToolkit.ps1

##================================================
## MARK: Variables
##================================================

# Zero-Config MSI support is provided when "AppName" is null or empty.
# By setting the "AppName" property, Zero-Config MSI will be disabled.
$adtSession = @{
    # App variables.
    AppVendor                   = 'Fortinet Inc.'
    AppName                     = 'FortiClient VPN'
    AppVersion                  = '7.4.3.1790'
    AppArch                     = 'x64'
    AppLang                     = 'EN'
    AppRevision                 = '01'
    AppSuccessExitCodes         = @(0)
    AppRebootExitCodes          = @(1641, 3010)
    AppProcessesToClose         = @(@{ Name = 'FortiClient'; Description = 'FortiClient Console' }, @{ Name = 'ipsec'; Description = 'FortiClient IPSec VPN Service' })  # Example: @('excel', @{ Name = 'winword'; Description = 'Microsoft Word' })
    AppScriptVersion            = '1.0.0'
    AppScriptDate               = '09/01/2025'
    AppScriptAuthor             = 'Ethan'
    RequireAdmin                = $true

    # Install Titles (Only set here to override defaults set by the toolkit).
    InstallName                 = ''
    InstallTitle                = ''

    # Script variables.
    DeployAppScriptFriendlyName = $MyInvocation.MyCommand.Name
    DeployAppScriptParameters   = $PSBoundParameters
    DeployAppScriptVersion      = '4.1.3'
}

function Install-ADTDeployment {
    [CmdletBinding()]
    param
    (
    )

    ##================================================
    ## MARK: Pre-Install
    ##================================================
    $adtSession.InstallPhase = "Pre-$($adtSession.DeploymentType)"

    ## Show Welcome Message, close processes if specified, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt.
    ## <Perform Pre-Installation tasks here>
    if ($adtSession.AppProcessesToClose.Count -gt 0) {
        $saiwParams = @{
            AllowDeferCloseProcesses = $true
            DeferTimes               = 3
            CheckDiskSpace           = $true
            PersistPrompt            = $true
            CustomText               = $true
            CloseProcesses           = $adtSession.AppProcessesToClose
            CloseProcessesCountdown  = 300
            DeferRunInterval         = ([System.TimeSpan]::FromHours(24))
        }
        Show-ADTInstallationWelcome @saiwParams

        ## Show Progress Message (with the default message).
        Show-ADTInstallationProgress
    }

    ##================================================
    ## MARK: Install
    ##================================================
    $adtSession.InstallPhase = $adtSession.DeploymentType

    ## Handle Zero-Config MSI installations.
    if ($adtSession.UseDefaultMsi) {
        $ExecuteDefaultMSISplat = @{ Action = $adtSession.DeploymentType; FilePath = $adtSession.DefaultMsiFile }
        if ($adtSession.DefaultMstFile) {
            $ExecuteDefaultMSISplat.Add('Transforms', $adtSession.DefaultMstFile)
        }
        Start-ADTMsiProcess @ExecuteDefaultMSISplat
        if ($adtSession.DefaultMspFiles) {
            $adtSession.DefaultMspFiles | Start-ADTMsiProcess -Action Patch
        }
    }
    
    ## <Perform Installation tasks here>
    Start-ADTMsiProcess -Action 'Install' -FilePath 'FortiClientVPN.msi' -ArgumentList '/passive /quiet INSTALLLEVEL=3 /NORESTART'

    ##================================================
    ## MARK: Post-Install
    ##================================================
    $adtSession.InstallPhase = "Post-$($adtSession.DeploymentType)"

    ## <Perform Post-Installation tasks here>
    $ConfigPW = "passwordhere"
    Start-ADTProcess -FilePath "C:\Program Files\Fortinet\FortiClient\FCConfig.exe" -ArgumentList "-m vpn -f `"$($adtSession.DirSupportFiles)\vpn.sconf`" -o import -p $ConfigPW" -WindowStyle 'Hidden'
    ## Display a message at the end of the install.
    ##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 -ButtonMiddleText 'Ok'
    ##}
    Show-ADTInstallationRestartPrompt -CountdownSeconds 300
}

Thanks

You either shouldn't specify a DeployMode at all, or should specify Auto instead so this is determined for you.

1 Like

Thanks. I set it to auto and it is working now.
If the process isn't open it runs in silent mode.

Only minor issue now is that it doesn't seem to be providing an exit code of 3010 to the Intune client, to notify users a reboot is required.

I am using this code to prompt a reboot

    if ($adtSession.DeploymentType -eq "Interactive") {
        #Display prompt to restart
        Show-ADTInstallationRestartPrompt -CountdownSeconds 300
    }
    else {
        # Get time till midnight
        $now = Get-Date
        $midnight = [datetime]::Today.AddDays(1)
        $secondsUntilMidnight = [int]($midnight - $now).TotalSeconds
        # Restart at midnight
        Show-ADTInstallationRestartPrompt -SilentRestart -SilentCountdownSeconds $secondsUntilMidnight
    }

These are some of the lines from the PSADT log:

[Install] :: Execution completed successfully with exit code [3010]. A reboot is required.

[Post-Install] :: Triggering restart silently because the deploy mode is set to [Silent] and [-SilentRestart] has been specified. Timeout is set to [56605] seconds.

[Finalization] :: [FortinetInc._FortiClientVPN_7.4.3.1790_x64_EN_01] install completed in [90.6192516] seconds with exit code [0].

Is there anyway to force PSADT to exit with a 3010 exit code, so that intune creates a restart notification? As I can't notify users using PSADT when it is in silent mode. (least I don't know how)

You just need to move your Show-ADTInstallationRestartPrompt call to be after the Close-ADTSession call as it won't care then about whether the session was silent or not. You'll need to manually specify -Title and -Subtitle though.

1 Like

Okay that makes sense. Thanks.
I guess I need to code it in a way that only displays it when user is logged in. If there is no active session it should just either schedule reboot at X time or force it.

Does PSADT have any native ability to determine this I can use after the ADT session is closed? I can see in the logs it determines who is the active session.
If you're not sure I will dig around on the docs. :slight_smile:

Thanks for your help again.

Just put the call to the dialog in an if ($runAsActiveUser) {...} branch.

Tried this but didn't see any dialog prompt or silent restart
any ideas?

##================================================
## MARK: Invocation
##================================================

# Commence the actual deployment operation.
try {
    # Import any found extensions before proceeding with the deployment.
    Get-ChildItem -LiteralPath $PSScriptRoot -Directory | & {
        process {
            if ($_.Name -match 'PSAppDeployToolkit\..+$') {
                Get-ChildItem -LiteralPath $_.FullName -Recurse -File | Unblock-File -ErrorAction Ignore
                Import-Module -Name $_.FullName -Force
            }
        }
    }

    # Invoke the deployment and close out the session.
    & "$($adtSession.DeploymentType)-ADTDeployment"
    Close-ADTSession
    
    if ($runAsActiveUser) {
        Show-ADTInstallationRestartPrompt -CountdownSeconds 300 -Title "This is a test title" -Subtitle "This is a subtitle to test"
    }
    else {
        Show-ADTInstallationRestartPrompt -SilentRestart
    }
    
}
catch {
    # An unhandled error has been caught.
    $mainErrorMessage = "An unhandled error within [$($MyInvocation.MyCommand.Name)] has occurred.`n$(Resolve-ADTErrorRecord -ErrorRecord $_)"
    Write-ADTLogEntry -Message $mainErrorMessage -Severity 3

    ## Error details hidden from the user by default. Show a simple dialog with full stack trace:
    # Show-ADTDialogBox -Text $mainErrorMessage -Icon Stop -NoWait

    ## Or, a themed dialog with basic error message:
    # Show-ADTInstallationPrompt -Message "$($adtSession.DeploymentType) failed at line $($_.InvocationInfo.ScriptLineNumber), char $($_.InvocationInfo.OffsetInLine):`n$($_.InvocationInfo.Line.Trim())`n`nMessage:`n$($_.Exception.Message)" -MessageAlignment Left -ButtonRightText OK -Icon Error -NoWait

    Close-ADTSession -ExitCode 60001
}


Apologies, mate. After having a coffee and looking at the code, I realised some tune-ups on our side would be required.

Once Expose `Exit-ADTInvocation`'s `-NoShellExit` parameter on `Close-ADTSession`. by mjr4077au · Pull Request #1704 · PSAppDeployToolkit/PSAppDeployToolkit · GitHub has been merged in and 4.1.4 is released, you'd do this:

##================================================
## MARK: Invocation
##================================================

# Commence the actual deployment operation.
try {
    # Import any found extensions before proceeding with the deployment.
    Get-ChildItem -LiteralPath $PSScriptRoot -Directory | & {
        process {
            if ($_.Name -match 'PSAppDeployToolkit\..+$') {
                Get-ChildItem -LiteralPath $_.FullName -Recurse -File | Unblock-File -ErrorAction Ignore
                Import-Module -Name $_.FullName -Force
            }
        }
    }

    # Invoke the deployment and close out the session.
    & "$($adtSession.DeploymentType)-ADTDeployment"
    $exitCode = Close-ADTSession -NoShellExit -PassThru
    
    if ($runAsActiveUser) {
        Show-ADTInstallationRestartPrompt -CountdownSeconds 300 -Title "This is a test title" -Subtitle "This is a subtitle to test"
    }
    else {
        Show-ADTInstallationRestartPrompt -SilentRestart
    }
    exit $exitCode
    
}
catch {
    # An unhandled error has been caught.
    $mainErrorMessage = "An unhandled error within [$($MyInvocation.MyCommand.Name)] has occurred.`n$(Resolve-ADTErrorRecord -ErrorRecord $_)"
    Write-ADTLogEntry -Message $mainErrorMessage -Severity 3

    ## Error details hidden from the user by default. Show a simple dialog with full stack trace:
    # Show-ADTDialogBox -Text $mainErrorMessage -Icon Stop -NoWait

    ## Or, a themed dialog with basic error message:
    # Show-ADTInstallationPrompt -Message "$($adtSession.DeploymentType) failed at line $($_.InvocationInfo.ScriptLineNumber), char $($_.InvocationInfo.OffsetInLine):`n$($_.InvocationInfo.Line.Trim())`n`nMessage:`n$($_.Exception.Message)" -MessageAlignment Left -ButtonRightText OK -Icon Error -NoWait

    Close-ADTSession -ExitCode 60001
}
1 Like

No worries. Thank you for the assistance and adding extra functionality to get it working in the way that I want! Much appreciated.
I'll patiently wait for 4.1.4 then.

1 Like

Hi mjr4077au,
I am still not seeing the restart prompt after the Close-ADTSession command completes.
I have added the -NoShellExit switch but it still seems to be exiting. It is also still exiting with an exit code of 0, despite the msi install giving a 3010 exit code. (perhaps I need to capture this??) Entire script below. I am running version 4.1.5 as I had issues deploying 4.1.4 via Intune.

If I look into event viewer > windows logs > security
I can see process terminations at the same h/m/s as when the psadt logs are reporting the session is closed. but there doesn't seem to be any process creation events for the prompt. I tried looking under application logs but saw nothing useful in there.

Let me know if you there is anything I can do to assist with troubleshooting this.

<#

.SYNOPSIS
PSAppDeployToolkit - This script performs the installation or uninstallation of an application(s).

.DESCRIPTION
- The script is provided as a template to perform an install, uninstall, or repair of an application(s).
- The script either performs an "Install", "Uninstall", or "Repair" deployment type.
- The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.

The script imports the PSAppDeployToolkit module which contains the logic and functions required to install or uninstall an application.

.PARAMETER DeploymentType
The type of deployment to perform.

.PARAMETER DeployMode
Specifies whether the installation should be run in Interactive (shows dialogs), Silent (no dialogs), NonInteractive (dialogs without prompts) mode, or Auto (shows dialogs if a user is logged on, device is not in the OOBE, and there's no running apps to close).

Silent mode is automatically set if it is detected that the process is not user interactive, no users are logged on, the device is in Autopilot mode, or there's specified processes to close that are currently running.

.PARAMETER SuppressRebootPassThru
Suppresses the 3010 return code (requires restart) from being 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 Desktop Session Hosts/Citrix servers.

.PARAMETER DisableLogging
Disables logging to file for the script.

.EXAMPLE
powershell.exe -File Invoke-AppDeployToolkit.ps1

.EXAMPLE
powershell.exe -File Invoke-AppDeployToolkit.ps1 -DeployMode Silent

.EXAMPLE
powershell.exe -File Invoke-AppDeployToolkit.ps1 -DeploymentType Uninstall

.EXAMPLE
Invoke-AppDeployToolkit.exe -DeploymentType Install -DeployMode Silent

.INPUTS
None. You cannot pipe objects to this script.

.OUTPUTS
None. This script does not generate any output.

.NOTES
Toolkit Exit Code Ranges:
- 60000 - 68999: Reserved for built-in exit codes in Invoke-AppDeployToolkit.ps1, and Invoke-AppDeployToolkit.exe
- 69000 - 69999: Recommended for user customized exit codes in Invoke-AppDeployToolkit.ps1
- 70000 - 79999: Recommended for user customized exit codes in PSAppDeployToolkit.Extensions module.

.LINK
https://psappdeploytoolkit.com

#>

[CmdletBinding()]
param
(
    # Default is 'Install'.
    [Parameter(Mandatory = $false)]
    [ValidateSet('Install', 'Uninstall', 'Repair')]
    [System.String]$DeploymentType,

    # Default is 'Auto'. Don't hard-code this unless required.
    [Parameter(Mandatory = $false)]
    [ValidateSet('Auto', 'Interactive', 'NonInteractive', 'Silent')]
    [System.String]$DeployMode,

    [Parameter(Mandatory = $false)]
    [System.Management.Automation.SwitchParameter]$SuppressRebootPassThru,

    [Parameter(Mandatory = $false)]
    [System.Management.Automation.SwitchParameter]$TerminalServerMode,

    [Parameter(Mandatory = $false)]
    [System.Management.Automation.SwitchParameter]$DisableLogging
)


##================================================
## MARK: Variables
##================================================

# Zero-Config MSI support is provided when "AppName" is null or empty.
# By setting the "AppName" property, Zero-Config MSI will be disabled.
$adtSession = @{
    # App variables.
    AppVendor = 'Fortinet Inc.'
    AppName = 'FortiClient VPN update'
    AppVersion = '7.4.3.1790'
    AppArch = 'x64'
    AppLang = 'EN'
    AppRevision = '01'
    AppSuccessExitCodes = @(0)
    AppRebootExitCodes = @(1641, 3010)
    AppProcessesToClose = @(@{ Name = 'FortiClient'; Description = 'FortiClient Console' }, @{ Name = 'ipsec'; Description = 'FortiClient IPSec VPN Service' })  # Example: @('excel', @{ Name = 'winword'; Description = 'Microsoft Word' })
    AppScriptVersion = '1.0.0'
    AppScriptDate = '2025-09-08'
    AppScriptAuthor = 'Ethan'
    RequireAdmin = $true

    # Install Titles (Only set here to override defaults set by the toolkit).
    InstallName = ''
    InstallTitle = ''

    # Script variables.
    DeployAppScriptFriendlyName = $MyInvocation.MyCommand.Name
    DeployAppScriptParameters = $PSBoundParameters
    DeployAppScriptVersion = '4.1.5'
}

function Install-ADTDeployment
{
    [CmdletBinding()]
    param
    (
    )

    ##================================================
    ## MARK: Pre-Install
    ##================================================
    $adtSession.InstallPhase = "Pre-$($adtSession.DeploymentType)"

    ## Show Welcome Message, close processes if specified, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt.
    ## <Perform Pre-Installation tasks here>
    if ($adtSession.AppProcessesToClose.Count -gt 0) {
        $saiwParams = @{
            AllowDeferCloseProcesses = $true
            DeferTimes               = 3
            CheckDiskSpace           = $true
            PersistPrompt            = $true
            CustomText               = $true
            CloseProcesses           = $adtSession.AppProcessesToClose
            CloseProcessesCountdown  = 300
            DeferRunInterval         = ([System.TimeSpan]::FromHours(24))
            Subtitle                 = 'Company Name - App update'
        }
        Show-ADTInstallationWelcome @saiwParams

        ## Show Progress Message (with the default message).
        Show-ADTInstallationProgress
    }


    ##================================================
    ## MARK: Install
    ##================================================
    $adtSession.InstallPhase = $adtSession.DeploymentType

    ## Handle Zero-Config MSI installations.
    if ($adtSession.UseDefaultMsi)
    {
        $ExecuteDefaultMSISplat = @{ Action = $adtSession.DeploymentType; FilePath = $adtSession.DefaultMsiFile }
        if ($adtSession.DefaultMstFile)
        {
            $ExecuteDefaultMSISplat.Add('Transforms', $adtSession.DefaultMstFile)
        }
        Start-ADTMsiProcess @ExecuteDefaultMSISplat
        if ($adtSession.DefaultMspFiles)
        {
            $adtSession.DefaultMspFiles | Start-ADTMsiProcess -Action Patch
        }
    }

    ## <Perform Installation tasks here>
    Start-ADTMsiProcess -Action 'Install' -FilePath 'FortiClientVPN.msi' -ArgumentList '/passive /quiet INSTALLLEVEL=3 /NORESTART'

    ##================================================
    ## MARK: Post-Install
    ##================================================
    $adtSession.InstallPhase = "Post-$($adtSession.DeploymentType)"

    ## <Perform Post-Installation tasks here>
    $ConfigPW = "yourpassword"
    Start-ADTProcess -FilePath "C:\Program Files\Fortinet\FortiClient\FCConfig.exe" -ArgumentList "-m vpn -f `"$($adtSession.DirSupportFiles)\vpn.sconf`" -o import -p $ConfigPW" -WindowStyle 'Hidden'

}

function Uninstall-ADTDeployment
{
    [CmdletBinding()]
    param
    (
    )

    ##================================================
    ## MARK: Pre-Uninstall
    ##================================================
    $adtSession.InstallPhase = "Pre-$($adtSession.DeploymentType)"

    ## If there are processes to close, show Welcome Message with a 60 second countdown before automatically closing.
    if ($adtSession.AppProcessesToClose.Count -gt 0)
    {
        Show-ADTInstallationWelcome -CloseProcesses $adtSession.AppProcessesToClose -CloseProcessesCountdown 60
    }

    ## Show Progress Message (with the default message).
    Show-ADTInstallationProgress

    ## <Perform Pre-Uninstallation tasks here>


    ##================================================
    ## MARK: Uninstall
    ##================================================
    $adtSession.InstallPhase = $adtSession.DeploymentType

    ## Handle Zero-Config MSI uninstallations.
    if ($adtSession.UseDefaultMsi)
    {
        $ExecuteDefaultMSISplat = @{ Action = $adtSession.DeploymentType; FilePath = $adtSession.DefaultMsiFile }
        if ($adtSession.DefaultMstFile)
        {
            $ExecuteDefaultMSISplat.Add('Transforms', $adtSession.DefaultMstFile)
        }
        Start-ADTMsiProcess @ExecuteDefaultMSISplat
    }

    ## <Perform Uninstallation tasks here>


    ##================================================
    ## MARK: Post-Uninstallation
    ##================================================
    $adtSession.InstallPhase = "Post-$($adtSession.DeploymentType)"

    ## <Perform Post-Uninstallation tasks here>
}

function Repair-ADTDeployment
{
    [CmdletBinding()]
    param
    (
    )

    ##================================================
    ## MARK: Pre-Repair
    ##================================================
    $adtSession.InstallPhase = "Pre-$($adtSession.DeploymentType)"

    ## If there are processes to close, show Welcome Message with a 60 second countdown before automatically closing.
    if ($adtSession.AppProcessesToClose.Count -gt 0)
    {
        Show-ADTInstallationWelcome -CloseProcesses $adtSession.AppProcessesToClose -CloseProcessesCountdown 60
    }

    ## Show Progress Message (with the default message).
    Show-ADTInstallationProgress

    ## <Perform Pre-Repair tasks here>


    ##================================================
    ## MARK: Repair
    ##================================================
    $adtSession.InstallPhase = $adtSession.DeploymentType

    ## Handle Zero-Config MSI repairs.
    if ($adtSession.UseDefaultMsi)
    {
        $ExecuteDefaultMSISplat = @{ Action = $adtSession.DeploymentType; FilePath = $adtSession.DefaultMsiFile }
        if ($adtSession.DefaultMstFile)
        {
            $ExecuteDefaultMSISplat.Add('Transforms', $adtSession.DefaultMstFile)
        }
        Start-ADTMsiProcess @ExecuteDefaultMSISplat
    }

    ## <Perform Repair tasks here>


    ##================================================
    ## MARK: Post-Repair
    ##================================================
    $adtSession.InstallPhase = "Post-$($adtSession.DeploymentType)"

    ## <Perform Post-Repair tasks here>
}


##================================================
## MARK: Initialization
##================================================

# Set strict error handling across entire operation.
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
$ProgressPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue
Set-StrictMode -Version 1

# Import the module and instantiate a new session.
try
{
    # Import the module locally if available, otherwise try to find it from PSModulePath.
    if (Test-Path -LiteralPath "$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1" -PathType Leaf)
    {
        Get-ChildItem -LiteralPath "$PSScriptRoot\PSAppDeployToolkit" -Recurse -File | Unblock-File -ErrorAction Ignore
        Import-Module -FullyQualifiedName @{ ModuleName = "$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1"; Guid = '8c3c366b-8606-4576-9f2d-4051144f7ca2'; ModuleVersion = '4.1.5' } -Force
    }
    else
    {
        Import-Module -FullyQualifiedName @{ ModuleName = 'PSAppDeployToolkit'; Guid = '8c3c366b-8606-4576-9f2d-4051144f7ca2'; ModuleVersion = '4.1.5' } -Force
    }

    # Open a new deployment session, replacing $adtSession with a DeploymentSession.
    $iadtParams = Get-ADTBoundParametersAndDefaultValues -Invocation $MyInvocation
    $adtSession = Remove-ADTHashtableNullOrEmptyValues -Hashtable $adtSession
    $adtSession = Open-ADTSession @adtSession @iadtParams -PassThru
}
catch
{
    $Host.UI.WriteErrorLine((Out-String -InputObject $_ -Width ([System.Int32]::MaxValue)))
    exit 60008
}


##================================================
## MARK: Invocation
##================================================

# Commence the actual deployment operation.
try
{
    # Import any found extensions before proceeding with the deployment.
    Get-ChildItem -LiteralPath $PSScriptRoot -Directory | & {
        process
        {
            if ($_.Name -match 'PSAppDeployToolkit\..+$')
            {
                Get-ChildItem -LiteralPath $_.FullName -Recurse -File | Unblock-File -ErrorAction Ignore
                Import-Module -Name $_.FullName -Force
            }
        }
    }

    # Invoke the deployment and close out the session.
    & "$($adtSession.DeploymentType)-ADTDeployment"
    $exitCode = Close-ADTSession -NoShellExit -PassThru
    ## Restart prompt done here to allow show prompt when running in silent mode and user is active.
    if ($runAsActiveUser) {
        Show-ADTInstallationRestartPrompt -CountdownSeconds 300 -Title "FortiClient VPN 7.4.3.1790" -Subtitle "Company Name - App Update"
    }
    else {
        Show-ADTInstallationRestartPrompt -SilentRestart
    }
    exit $exitCode
}
catch
{
    # An unhandled error has been caught.
    $mainErrorMessage = "An unhandled error within [$($MyInvocation.MyCommand.Name)] has occurred.`n$(Resolve-ADTErrorRecord -ErrorRecord $_)"
    Write-ADTLogEntry -Message $mainErrorMessage -Severity 3

    ## Error details hidden from the user by default. Show a simple dialog with full stack trace:
    # Show-ADTDialogBox -Text $mainErrorMessage -Icon Stop -NoWait

    ## Or, a themed dialog with basic error message:
    # Show-ADTInstallationPrompt -Message "$($adtSession.DeploymentType) failed at line $($_.InvocationInfo.ScriptLineNumber), char $($_.InvocationInfo.OffsetInLine):`n$($_.InvocationInfo.Line.Trim())`n`nMessage:`n$($_.Exception.Message)" -MessageAlignment Left -ButtonRightText OK -Icon Error -NoWait

    Close-ADTSession -ExitCode 60001
}


PSADT log:

<![LOG[-------------------------------------------------------------------------------]LOG]!><time="08:19:00.461+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [FortinetInc._FortiClientVPNupdate_7.4.3.1790_x64_EN_01] install started.]LOG]!><time="08:19:00.504+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [FortinetInc._FortiClientVPNupdate_7.4.3.1790_x64_EN_01] script version is [1.0.0].]LOG]!><time="08:19:00.506+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [FortinetInc._FortiClientVPNupdate_7.4.3.1790_x64_EN_01] script date is [2025-09-08].]LOG]!><time="08:19:00.506+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [FortinetInc._FortiClientVPNupdate_7.4.3.1790_x64_EN_01] script author is [Ethan].]LOG]!><time="08:19:00.509+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [Invoke-AppDeployToolkit.ps1] script version is [4.1.5].]LOG]!><time="08:19:00.509+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The following parameters were passed to [Invoke-AppDeployToolkit.ps1]: [-DeploymentType:'Install'].]LOG]!><time="08:19:00.513+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] module version is [4.1.5].]LOG]!><time="08:19:00.513+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] module imported in [3.5798362] seconds.]LOG]!><time="08:19:00.515+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] module initialized in [3.264685] seconds.]LOG]!><time="08:19:00.515+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] module path is ['C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit'].]LOG]!><time="08:19:00.515+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] config path is ['C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\Config'].]LOG]!><time="08:19:00.517+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] string path is ['C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\Strings'].]LOG]!><time="08:19:00.517+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] session mode is [Native].]LOG]!><time="08:19:00.520+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Computer Name is [SFW-VM-E4FE04E9].]LOG]!><time="08:19:00.520+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Current User is [NT AUTHORITY\SYSTEM].]LOG]!><time="08:19:00.523+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: OS Version is [Microsoft Windows 11 Enterprise X64 10.0.26100.4946].]LOG]!><time="08:19:00.523+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: OS Type is [WorkStation].]LOG]!><time="08:19:00.525+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Hardware Platform is [Virtual:VMware].]LOG]!><time="08:19:00.525+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Current Culture is [en-AU], language is [EN] and UI language is [EN].]LOG]!><time="08:19:00.527+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: PowerShell Host is [ConsoleHost] with version [5.1.26100.4768].]LOG]!><time="08:19:00.527+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: PowerShell Version is [5.1.26100.4768 X64].]LOG]!><time="08:19:00.529+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: PowerShell Process Path is [C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe].]LOG]!><time="08:19:00.529+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: PowerShell CLR (.NET) version is [4.0.30319.42000].]LOG]!><time="08:19:00.531+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The following users are logged on to the system: [AzureAD\Ethan].]LOG]!><time="08:19:00.534+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Session information for all logged on users:
 
NTAccount             : AzureAD\Ethan
SID                   : <SID HERE>
UserName              : Ethan
DomainName            : AzureAD
SessionId             : 1
SessionName           : Console
ConnectState          : WTSActive
IsCurrentSession      : False
IsConsoleSession      : True
IsActiveUserSession   : True
IsValidUserSession    : True
IsUserSession         : True
IsRdpSession          : False
IsLocalAdmin          : False
IsLocalAdminException : 
LogonTime             : 8/09/2025 8:04:28 AM
IdleTime              : 00:01:00.5000000
DisconnectTime        : 
ClientName            : 
ClientProtocolType    : Console
ClientDirectory       : 
ClientBuildNumber     :
]LOG]!><time="08:19:00.534+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Current process is running under a system account [NT AUTHORITY\SYSTEM].]LOG]!><time="08:19:00.536+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The following user is the console user [AzureAD\Ethan] (user with control of physical monitor, keyboard, and mouse).]LOG]!><time="08:19:00.536+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The active logged on user who will receive UI elements is [AzureAD\Ethan].]LOG]!><time="08:19:00.539+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The current execution context has a primary UI language of [en-US].]LOG]!><time="08:19:00.539+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The following locale was used to import UI messages from the strings.psd1 files: [en-AU].]LOG]!><time="08:19:00.541+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Unable to find COM object [Microsoft.SMS.TSEnvironment]. Therefore, script is not currently running from a SCCM Task Sequence.]LOG]!><time="08:19:00.541+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Device has completed the OOBE and toolkit is not running with an active ESP in progress.]LOG]!><time="08:19:00.544+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Session 0 detected, user(s) logged on to interact if required.]LOG]!><time="08:19:00.546+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The processes ['FortiClient', 'ipsec'] were specified as requiring closure but none were running, changing deployment mode to [Silent].]LOG]!><time="08:19:00.556+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Installation is running in [Silent] mode.]LOG]!><time="08:19:00.558+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Deployment type is [Install].]LOG]!><time="08:19:00.558+600" date="9-08-2025" component="Open-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Module [PSAppDeployToolkit.Extensions] imported successfully.]LOG]!><time="08:19:00.704+600" date="9-08-2025" component="PSAppDeployToolkit.Extensions.psm1" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit.Extensions\PSAppDeployToolkit.Extensions.psm1">
<![LOG[[Pre-Install] :: Running Show-ADTInstallationWelcome silently as the current deployment is NonInteractive or Silent.]LOG]!><time="08:19:00.770+600" date="9-08-2025" component="Show-ADTInstallationWelcome" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Pre-Install] :: Evaluating disk space requirements.]LOG]!><time="08:19:00.779+600" date="9-08-2025" component="Show-ADTInstallationWelcome" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Pre-Install] :: Retrieving free disk space for drive [C:\].]LOG]!><time="08:19:00.812+600" date="9-08-2025" component="Get-ADTFreeDiskSpace" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Pre-Install] :: Free disk space for drive [C:\]: [91161 MB].]LOG]!><time="08:19:00.816+600" date="9-08-2025" component="Get-ADTFreeDiskSpace" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Pre-Install] :: Successfully passed minimum disk space requirement check.]LOG]!><time="08:19:00.821+600" date="9-08-2025" component="Show-ADTInstallationWelcome" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Pre-Install] :: Checking for running processes: ['FortiClient', 'ipsec']]LOG]!><time="08:19:00.828+600" date="9-08-2025" component="Get-ADTRunningProcesses" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Pre-Install] :: Specified processes are not running.]LOG]!><time="08:19:00.833+600" date="9-08-2025" component="Get-ADTRunningProcesses" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Pre-Install] :: Bypassing Show-ADTInstallationProgress [Mode: Silent]. Status message: System.Collections.Hashtable]LOG]!><time="08:19:00.855+600" date="9-08-2025" component="Show-ADTInstallationProgress" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Executing MSI action [Install]...]LOG]!><time="08:19:00.888+600" date="9-08-2025" component="Start-ADTMsiProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Reading data from Windows Installer database file [C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\Files\FortiClientVPN.msi] in table [Property].]LOG]!><time="08:19:00.939+600" date="9-08-2025" component="Get-ADTMsiTableProperty" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Getting information for installed applications...]LOG]!><time="08:19:02.006+600" date="9-08-2025" component="Get-ADTApplication" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Found no application based on the supplied FilterScript.]LOG]!><time="08:19:02.039+600" date="9-08-2025" component="Get-ADTApplication" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Preparing to execute process [C:\WINDOWS\system32\msiexec.exe]...]LOG]!><time="08:19:02.163+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Checking to see if mutex [Global\_MSIExecute] is available. Wait up to [10 minute(s)] for the mutex to become available.]LOG]!><time="08:19:02.177+600" date="9-08-2025" component="Test-ADTMutexAvailability" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Mutex [Global\_MSIExecute] is available for an exclusive lock.]LOG]!><time="08:19:02.184+600" date="9-08-2025" component="Test-ADTMutexAvailability" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: CreateNoWindow not specified, StdOut/StdErr streams will not be available.]LOG]!><time="08:19:03.211+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Working Directory is [C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\Files].]LOG]!><time="08:19:03.213+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Executing ["C:\WINDOWS\system32\msiexec.exe" /i C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\Files\FortiClientVPN.msi /passive /quiet INSTALLLEVEL=3 /NORESTART /L*V C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\FortiClientVPN_7.4.3.1790_Install.log]...]LOG]!><time="08:19:03.218+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Executed ["C:\WINDOWS\system32\msiexec.exe" /i C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\Files\FortiClientVPN.msi /passive /quiet INSTALLLEVEL=3 /NORESTART /L*V C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\FortiClientVPN_7.4.3.1790_Install.log], awaiting completion...]LOG]!><time="08:19:03.241+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Execution completed successfully with exit code [3010]. A reboot is required.]LOG]!><time="08:20:27.511+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="2" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: StdOut Output from Execution: N/A]LOG]!><time="08:20:27.520+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: StdErr Output from Execution: N/A]LOG]!><time="08:20:27.524+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Interleaved Output from Execution: N/A]LOG]!><time="08:20:27.526+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Refreshing the Desktop and the Windows Explorer environment process block.]LOG]!><time="08:20:27.666+600" date="9-08-2025" component="Update-ADTDesktop" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Instantiating user client/server process.]LOG]!><time="08:20:27.709+600" date="9-08-2025" component="Invoke-ADTClientServerOperation" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Post-Install] :: Preparing to execute process [C:\Program Files\Fortinet\FortiClient\FCConfig.exe]...]LOG]!><time="08:20:28.144+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Post-Install] :: CreateNoWindow not specified, StdOut/StdErr streams will not be available.]LOG]!><time="08:20:28.152+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Post-Install] :: Working Directory is [C:\Program Files\Fortinet\FortiClient].]LOG]!><time="08:20:28.154+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Post-Install] :: Executing ["C:\Program Files\Fortinet\FortiClient\FCConfig.exe" -m vpn -f "C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\SupportFiles\griffithvpn.sconf" -o import -p GriffithUni]...]LOG]!><time="08:20:28.159+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Post-Install] :: Executed ["C:\Program Files\Fortinet\FortiClient\FCConfig.exe" -m vpn -f "C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\SupportFiles\griffithvpn.sconf" -o import -p GriffithUni], awaiting completion...]LOG]!><time="08:20:28.171+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Post-Install] :: Execution completed successfully with exit code [0].]LOG]!><time="08:20:29.560+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="0" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Post-Install] :: StdOut Output from Execution: N/A]LOG]!><time="08:20:29.562+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Post-Install] :: StdErr Output from Execution: N/A]LOG]!><time="08:20:29.564+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Post-Install] :: Interleaved Output from Execution: N/A]LOG]!><time="08:20:29.566+600" date="9-08-2025" component="Start-ADTProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Finalization] :: Closing user client/server process.]LOG]!><time="08:20:29.596+600" date="9-08-2025" component="Close-ADTClientServerProcess" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Finalization] :: [FortinetInc._FortiClientVPNupdate_7.4.3.1790_x64_EN_01] install completed in [89.18287] seconds with exit code [0].]LOG]!><time="08:20:29.640+600" date="9-08-2025" component="Close-ADTSession" context="NT AUTHORITY\SYSTEM" type="0" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[-------------------------------------------------------------------------------]LOG]!><time="08:20:29.643+600" date="9-08-2025" component="Close-ADTSession" context="NT AUTHORITY\SYSTEM" type="1" thread="2412" file="C:\WINDOWS\IMECache\7cf34efe-0005-4d64-b009-236d00d6f421_1\PSAppDeployToolkit\PSAppDeployToolkit.psm1">

I'll have a test next time I'm on the laptop. It's important to note that logging will have ended after the Close-ADTSession call, so we can't rely on the log to see what's going on. You should be testing locally outside of Intune before you package up the app.

I tried locally and got the same issue.

Revert the bottom of Invoke-AppDeployToolkit.ps1 back to how it was, then add this after the catch block:

finally
{
    if (!(Get-Variable -Name mainErrorMessage -ErrorAction Ignore))
    {
        if ($runAsActiveUser)
        {
            Show-ADTInstallationRestartPrompt -CountdownSeconds 300 -Title "This is a test title" -Subtitle "This is a subtitle to test"
        }
        else
        {
            Show-ADTInstallationRestartPrompt -SilentRestart -SilentCountdownSeconds 300
        }
    }
}

We'll look at just adding a -Force parameter into 4.2.0 so you don't have to jump through so many hoops.

1 Like

Hi mjr4077au,
That worked well. Thank you very much for your assistance!
A final question, the icon displayed in my Show-ADTInstallationPrompt is the default one. I imagine there is no way for me to load my custom icon? As that information is wiped after the Close-ADTSession command runs? If it's not possible without a lot of work, no worries, mark this one as complete and I'll revisit it if/when the -force parameter gets added.
Thanks again for your assistance.

You'd have to re-init the module yourself via Initialize-ADTModule -ScriptDirectory $PSScriptRoot. Let me know how that goes.

1 Like

That seemed to work, thanks, logo is now appearing.
Do I need to remove the psadt module or do any manual cleanup after it has been initialized? or should it work as normal next time psadt is run?

Nah, you're only initialising it for that PowerShell session. All of that's lost when PowerShell exits. The reason you don't have to manually initialise the module yourself is because Open-ADTSession will do it for you, but of course here we don't wish to open a new session again.

Okay cool, I thought that may have been the case but wasn't sure if PSADT did other things in the backend. All sorted now thank you very much!

I'd have to slap myself on the face if initialising the module did anything to modify the module. Consider the module immutable, we do which is why you can't modify its config files, etc, and have to adjust the config in the Config directory along-side your script, etc.