Update samy.functions.ps1
This commit is contained in:
@@ -87,15 +87,54 @@ function Initialize-NuGetProvider {
|
|||||||
|
|
||||||
#region App handlers
|
#region App handlers
|
||||||
|
|
||||||
function Invoke-Install1Password { param($Context)
|
function Invoke-Install1Password {
|
||||||
|
param($Context)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
winget install --id=1Password.1Password --silent --accept-package-agreements --accept-source-agreements
|
# Default if called without suboptions
|
||||||
Write-LogHybrid "Installed 1Password via winget" Success SVSApps -LogToEvent
|
$selected = @('desktop')
|
||||||
Send-Text $Context "1Password installed"
|
|
||||||
} catch {
|
# If JS POSTs { checkedValues: [...] }, use that
|
||||||
|
if ($Context -and $Context.Request -and $Context.Request.HttpMethod -eq 'POST') {
|
||||||
|
$raw = (New-Object IO.StreamReader $Context.Request.InputStream).ReadToEnd()
|
||||||
|
if (-not [string]::IsNullOrWhiteSpace($raw)) {
|
||||||
|
$data = $raw | ConvertFrom-Json
|
||||||
|
if ($data.checkedValues) { $selected = @($data.checkedValues) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Extension IDs from official store listings
|
||||||
|
$chromeExtId = 'aeblfdkhhhdcdjpifhhbdiojplfjncoa' # Chrome Web Store :contentReference[oaicite:1]{index=1}
|
||||||
|
$edgeExtId = 'dppgmdbiimibapkepcbdbmkaabgiofem' # Edge Add-ons :contentReference[oaicite:2]{index=2}
|
||||||
|
|
||||||
|
if ($selected -contains 'desktop') {
|
||||||
|
winget install -e --id AgileBits.1Password --silent --accept-package-agreements --accept-source-agreements
|
||||||
|
Write-LogHybrid "Installed 1Password desktop app via winget" Success SVSApps -LogToEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($selected -contains 'chromeExt') {
|
||||||
|
$chromeKey = "HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist"
|
||||||
|
New-Item -Path $chromeKey -Force | Out-Null
|
||||||
|
New-ItemProperty -Path $chromeKey -Name "1" -PropertyType String -Force `
|
||||||
|
-Value "$chromeExtId;https://clients2.google.com/service/update2/crx" | Out-Null
|
||||||
|
Write-LogHybrid "Forced 1Password extension install for Chrome" Success SVSApps -LogToEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($selected -contains 'edgeExt') {
|
||||||
|
$edgeKey = "HKLM:\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallForcelist"
|
||||||
|
New-Item -Path $edgeKey -Force | Out-Null
|
||||||
|
New-ItemProperty -Path $edgeKey -Name "1" -PropertyType String -Force `
|
||||||
|
-Value "$edgeExtId;https://edge.microsoft.com/extensionwebstorebase/v1/crx" | Out-Null
|
||||||
|
Write-LogHybrid "Forced 1Password extension install for Edge" Success SVSApps -LogToEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
Send-Text $Context "1Password processed: $($selected -join ', ')"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
Write-LogHybrid "1Password install failed: $($_.Exception.Message)" Error SVSApps -LogToEvent
|
Write-LogHybrid "1Password install failed: $($_.Exception.Message)" Error SVSApps -LogToEvent
|
||||||
Send-Text $Context "ERROR: $($_.Exception.Message)"
|
Send-Text $Context "ERROR: $($_.Exception.Message)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion App handlers
|
#endregion App handlers
|
||||||
|
|||||||
Reference in New Issue
Block a user