fleet/ee/maintained-apps/inputs/winget/scripts/figma_install.ps1
Allen Houchins 092298cc13
Add Figma as a FMA for Windows (#35815)
Introduces Figma as a managed application for Windows, including input
metadata, install and uninstall PowerShell scripts, and output
definitions for version 125.10.4. Updates the apps.json registry to
include Figma for Windows.

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] If paths of existing endpoints are modified without backwards
compatibility, checked the frontend/CLI for any necessary changes

## Testing

- [ ] Added/updated automated tests
- [ ] Where appropriate, [automated tests simulate multiple hosts and
test for host
isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing)
(updates to one hosts's records do not affect another)

- [ ] QA'd all new/changed functionality manually

For unreleased bug fixes in a release candidate, one of:

- [ ] Confirmed that the fix is not expected to adversely impact load
test results
- [ ] Alerted the release DRI if additional load testing is needed

## Database migrations

- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).

## New Fleet configuration settings

- [ ] Setting(s) is/are explicitly excluded from GitOps

If you didn't check the box above, follow this checklist for
GitOps-enabled settings:

- [ ] Verified that the setting is exported via `fleetctl
generate-gitops`
- [ ] Verified the setting is documented in a separate PR to [the GitOps
documentation](https://github.com/fleetdm/fleet/blob/main/docs/Configuration/yaml-files.md#L485)
- [ ] Verified that the setting is cleared on the server if it is not
supplied in a YAML file (or that it is documented as being optional)
- [ ] Verified that any relevant UI is disabled when GitOps mode is
enabled

## fleetd/orbit/Fleet Desktop

- [ ] Verified compatibility with the latest released version of Fleet
(see [Must
rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md))
- [ ] If the change applies to only one platform, confirmed that
`runtime.GOOS` is used as needed to isolate changes
- [ ] Verified that fleetd runs on macOS, Linux and Windows
- [ ] Verified auto-update works from the released version of component
to the new version (see [tools/tuf/test](../tools/tuf/test/README.md))
2025-11-17 13:57:06 -06:00

80 lines
2.5 KiB
PowerShell

$exeFilePath = "${env:INSTALLER_PATH}"
$exitCode = 0
try {
# Copy the installer to a public folder so that all users can access it
$exeFilename = Split-Path $exeFilePath -leaf
Copy-Item -Path $exeFilePath -Destination "${env:PUBLIC}" -Force
$exeFilePath = "${env:PUBLIC}\$exeFilename"
# Task properties. The task will be started by the logged in user
# Figma uses -s for silent installation (Squirrel installer)
$action = New-ScheduledTaskAction -Execute "$exeFilePath" -Argument "-s"
$trigger = New-ScheduledTaskTrigger -AtLogOn
$userName = (Get-CimInstance Win32_Process -Filter 'name = "explorer.exe"' | Invoke-CimMethod -MethodName getowner).User
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries
# Create a task object with the properties defined above
$task = New-ScheduledTask -Action $action -Trigger $trigger `
-Settings $settings
# Register the task
$taskName = "fleet-install-$exeFilename"
Register-ScheduledTask "$taskName" -InputObject $task -User "$userName"
# keep track of the start time to cancel if taking too long to start
$startDate = Get-Date
# Start the task now that it is ready
Start-ScheduledTask -TaskName "$taskName" -TaskPath "\"
# Wait for the task to be running
$state = (Get-ScheduledTask -TaskName "$taskName").State
Write-Host "ScheduledTask is '$state'"
while ($state -ne "Running") {
Write-Host "ScheduledTask is '$state'. Waiting to run .exe..."
$endDate = Get-Date
$elapsedTime = New-Timespan -Start $startDate -End $endDate
if ($elapsedTime.TotalSeconds -gt 120) {
Throw "Timed-out waiting for scheduled task state."
}
Start-Sleep -Seconds 1
$state = (Get-ScheduledTask -TaskName "$taskName").State
}
# Wait for the task to be done
$state = (Get-ScheduledTask -TaskName "$taskName").State
while ($state -eq "Running") {
Write-Host "ScheduledTask is '$state'. Waiting for .exe to complete..."
$endDate = Get-Date
$elapsedTime = New-Timespan -Start $startDate -End $endDate
if ($elapsedTime.TotalSeconds -gt 120) {
Throw "Timed-out waiting for scheduled task state."
}
Start-Sleep -Seconds 10
$state = (Get-ScheduledTask -TaskName "$taskName").State
}
# Wait a moment for registry to update after installation
Start-Sleep -Seconds 2
# Remove task
Write-Host "Removing ScheduledTask: $taskName."
Unregister-ScheduledTask -TaskName "$taskName" -Confirm:$false
} catch {
Write-Host "Error: $_"
$exitCode = 1
} finally {
# Remove installer
Remove-Item -Path $exeFilePath -Force -ErrorAction SilentlyContinue
}
Exit $exitCode