How to Install UiPath Extension using Invoke Power Shell activity?

We have a requirement to install UiPath extension in our robot machines if it is not yet installed.

Executing the offline options manually on PowerShell runs smoothly; however, it does not work when executing it using Invoke Power Shell activity. Has anyone tried making it work before?

Here’s the current setup on the Invoke Power Shell activity:

Command
in_BrowserType.ToLower().Trim() == “chrome”
? “&"C:\Program Files\UiPath\Studio\UiPath\SetupExtensions.exe" /chrome-policy-offline /silent”
: “&"C:\Program Files\UiPath\Studio\UiPath\SetupExtensions.exe" /edge-policy-offline /silent”

IsScript
true

The activity ran successfully but it did not install the extension as it’s not available in the extensions.

Appreciate your inputs and guidance on this matter. Thank you.

@iamjaredm Can you try the below step and please let me know if it works

Step 1: Now test from UiPath

In UiPath, keep your Invoke Power Shell activity like this:

IsScript: True

CommandText for Chrome:

$ErrorActionPreference = “Stop”

$setupPath = “C:\Program Files\UiPath\Studio\UiPath\SetupExtensions.exe”

if (!(Test-Path $setupPath)) {
$setupPath = “$env:LOCALAPPDATA\Programs\UiPath\Studio\UiPath\SetupExtensions.exe”
}

if (!(Test-Path $setupPath)) {
throw “SetupExtensions.exe not found”
}

& $setupPath /Chrome-Policy-Offline /silent

“ExitCode=$LASTEXITCODE”

For Edge:
$ErrorActionPreference = “Stop”

$setupPath = “C:\Program Files\UiPath\Studio\UiPath\SetupExtensions.exe”

if (!(Test-Path $setupPath)) {
$setupPath = “$env:LOCALAPPDATA\Programs\UiPath\Studio\UiPath\SetupExtensions.exe”
}

if (!(Test-Path $setupPath)) {
throw “SetupExtensions.exe not found”
}

& $setupPath /Edge-Policy-Offline /silent

“ExitCode=$LASTEXITCODE”

Step 2: Important setting in Invoke Power Shell

In the activity properties:

IsScript = True
Execution Mode = PowerShell 7.2.15 or Windows PowerShell
Output = psOutput

Create one variable:
psOutput, Type: Collection or use the type suggested by UiPath when you create the output variable.

Then add a Log Message after Invoke Power Shell:

String.Join(Environment.NewLine, psOutput)
This will show whether the command returned anything.

Step 3: Restart browser and check again

After the UiPath run completes:

Close Chrome/Edge completely.
Reopen browser.
Go to:
chrome://extensions
edge://extensions
Check whether UiPath Web Automation is installed.

@iamjaredm

  1. You need elevated permissions to run this as silent is used it might not show the error also
  2. when you sent paramters you need to declare the parameter at the top Param([string]$BrowserType) and then add the parameter in the input as well with same name and pass the value..using tolower trim should be done before passing the parameter not inside

a sample - Activities - Invoke Power Shell

Param([string]$BrowserType)
$exe = "C:\Program Files\UiPath\Studio\UiPath\SetupExtensions.exe"
 $arg = if ($BrowserType.ToLower().Trim() -eq "chrome") { "/chrome-policy-offline" } else { "/edge-policy-offline" }
Start-Process $exe -ArgumentList $arg, "/silent" -Wait

Also depending on the type of installation you have you need to use different commands

list is here - Studio - SetupExtensions tool

cheers

Hi @iamjaredm ,

We have build a process using powershell to upgrade/install chrome and check if UiPath extension exists if not powershell script will add that, here is the piece of code we are using which is working great for us

$preferencesPath = $in_PreferenceFilePath

if (Test-Path $preferencesPath) {
$preferences = Get-Content -Path $preferencesPath -Raw | ConvertFrom-Json

$extensions = $preferences.extensions.settings.PSObject.Properties.Name

$uipathExists = $false
$uipathEnabled = $false

foreach ($extension in $extensions) {
    $extensionDetails = $preferences.extensions.settings.$extension
    $extensionName = $extensionDetails.manifest.name
    $extensionVersion = $extensionDetails.manifest.version
    $extensionEnabled = $extensionDetails.state -eq 1

    if ($extensionName -like "*UiPath*") {
        Write-Output "Extension: $extensionName, Version: $extensionVersion, Enabled: $extensionEnabled"
        $uipathExists = $true
        $uipathEnabled = $extensionEnabled
    }
}

# If UiPath extension exists but is not enabled, enable it
if ($uipathExists -and -not $uipathEnabled) {
    Write-Output "UiPath extension found but not enabled. Enabling UiPath extension..."

    $regFilePath = $in_BrowserRegLocalFilePath
    Start-Process -FilePath "reg.exe" -ArgumentList "import `"$regFilePath`"" -NoNewWindow -Wait

    Write-Output "UiPath extension enabled."
}

# If UiPath extension does not exist, install it
if (-not $uipathExists) {
    Write-Output "UiPath extension not found. Installing UiPath extension..."

    Start-Process -FilePath $in_UiPathSetUpExtensionFilePath -ArgumentList "/chromecleanup /silent" -Wait
    Start-Sleep -Seconds 10

    Start-Process -FilePath $in_UiPathSetUpExtensionFilePath -ArgumentList "/chromeglobal /silent" -Wait
    Start-Sleep -Seconds 5

    Start-Process -FilePath "chrome.exe"
    Start-Sleep -Seconds 10

    $regFilePath = $in_BrowserRegLocalFilePath
    Start-Process -FilePath "reg.exe" -ArgumentList "import `"$regFilePath`"" -NoNewWindow -Wait

    Stop-Process -Name "chrome" -Force -ErrorAction SilentlyContinue

    Write-Output "UiPath extension installed and registry updated."
}

}
else {
Write-Output “Preferences file not found: $preferencesPath”
}