Monday, 20 January 2025

PSAppDeployToolkit in Intune to Check Interactive Session and Install Application with Notifications

 

How to Use PSAppDeployToolkit in Intune to Check Interactive Session and Install Google Chrome with Notifications

Managing software installation across an organization’s devices can be a challenging task for IT administrators, especially when dealing with complex scenarios like ensuring that installations occur only when certain conditions are met. One such condition might be whether a user is logged in interactively and if the target application (like Google Chrome) is running.

In this blog post, we'll guide you through the process of using PSSTool (PowerShell Script Tool) in Microsoft Intune to check for an active interactive session, check whether Google Chrome is already running, and install the browser with appropriate notifications for the user. We’ll use a custom PowerShell script to make this happen.

Scenario Overview

For this scenario, the goal is to:

· Check for an interactive session on the device.

· Detect if Google Chrome is already running.

· Install Google Chrome using a silent mode if the application is not running.

· Display appropriate notifications during the installation process.

The Script Explained

The PowerShell script you're going to use will check if Google Chrome is running, determine the correct installation method based on that, and install Chrome in a way that respects the user’s session. Here's the script you’ll deploy:

powershell

Copy

# Check if Google Chrome is running

$ChromeProcesses = @(Get-WmiObject -Query "select * FROM Win32_process WHERE name='Chrome.exe'" -ErrorAction SilentlyContinue)

 

if ($ChromeProcesses.Count -eq 0) {

    # If Chrome is not running, initiate installation in Session 0 (Non-Interactive mode)

    Try {

        Write-Output "Google Chrome is not started, we can run the installation in session 0"

        Start-Process Deploy-Application.exe -Wait -ArgumentList '-DeployMode "NonInteractive"'

    }

    Catch {

        $ErrorMessage = $_.Exception.Message

        Write-Error "Error: $ErrorMessage"

    }

} else {

    # If Chrome is running, initiate installation in Session 1 (Interactive mode)

    Try {

        Write-Output "Google Chrome is started, we need to run the installation in session 1 using ServiceUI.exe"

        .\ServiceUI.exe -process:explorer.exe Deploy-Application.exe

    }

    Catch {

        $ErrorMessage = $_.Exception.Message

        Write-Error "Error: $ErrorMessage"

    }

}

 

# Output the installation exit code

Write-Output "Exit Code of installation is: $LASTEXITCODE"

exit $LASTEXITCODE

Conclusion

Using PSAppDeployToolkit in Microsoft Intune to check for an interactive session and install Google Chrome with notifications is a great way to automate software installation while ensuring minimal disruption to users. By checking if Chrome is already running and using ServiceUI.exe to interact with the logged-in user, you create a smoother and more efficient deployment process.

More details about PSAppDeployToolkit- https://psappdeploytoolkit.com/docs/3.10.2/examples/googlechrome-configmgr

No comments:

Post a Comment

PSAppDeployToolkit in Intune to Check Interactive Session and Install Application with Notifications

  How to Use PSAppDeployToolkit  in Intune to Check Interactive Session and Install Google Chrome with Notifications Managing software insta...