#Requires -RunAsAdministrator param( [Parameter(Mandatory = $true)] [string]$CertificatePath ) $source = (Resolve-Path -LiteralPath $CertificatePath -ErrorAction Stop).Path $qzDirectory = Join-Path $env:ProgramFiles 'QZ Tray' $target = Join-Path $qzDirectory 'override.crt' if (-not (Test-Path -LiteralPath $qzDirectory -PathType Container)) { throw "QZ Tray is not installed at $qzDirectory" } $certificate = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new($source) if (-not $certificate.Subject.Contains('CN=Fueltorque QZ Root CA')) { throw 'The selected certificate is not the Fueltorque QZ root certificate.' } Get-Process -ErrorAction SilentlyContinue | Where-Object { ($_.ProcessName -like 'qz-tray*') -or ($_.ProcessName -eq 'javaw' -and $_.Path -like "$qzDirectory*") } | Stop-Process -Force if (Test-Path -LiteralPath $target -PathType Leaf) { $backup = "$target.$(Get-Date -Format 'yyyyMMddHHmmss').bak" Copy-Item -LiteralPath $target -Destination $backup Write-Host "Backed up the previous QZ trust certificate to $backup" } Copy-Item -LiteralPath $source -Destination $target Write-Host "Installed the Fueltorque QZ trust certificate at $target" $qzExecutable = Join-Path $qzDirectory 'qz-tray.exe' if (Test-Path -LiteralPath $qzExecutable -PathType Leaf) { Start-Process -FilePath $qzExecutable -WindowStyle Hidden Write-Host 'QZ Tray restarted.' }