44 lines
1.3 KiB
PowerShell
44 lines
1.3 KiB
PowerShell
|
#Zebra - 2/22/2024
|
||
|
#Installs extension of your choice to firefox, chrome, or edge.
|
||
|
#Must include the following arguments: -browserType -extensionID
|
||
|
|
||
|
param (
|
||
|
[string]$browserType = "Edge",
|
||
|
[string]$extensionID
|
||
|
)
|
||
|
|
||
|
#Selecting the registry path to install the extension to. Defaults to msedge
|
||
|
|
||
|
switch -Regex ($browserType.ToLower()) {
|
||
|
"chrome" {
|
||
|
$registryPath = "HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist"
|
||
|
}
|
||
|
"edge" {
|
||
|
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallForcelist"
|
||
|
}
|
||
|
"firefox" {
|
||
|
$registryPath = "HKLM:\SOFTWARE\Mozilla\Firefox\Extensions"
|
||
|
}
|
||
|
Default {
|
||
|
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallForcelist"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# Checking if the registry path exists, if not, create it
|
||
|
if (!(Test-Path $registryPath)) {
|
||
|
New-Item -Path $registryPath -Force
|
||
|
}
|
||
|
|
||
|
# Checking the registry to find the highest number key
|
||
|
$existingKeys = Get-ItemProperty -Path $registryPath | ForEach-Object { [int]($_.PSChildName) } | Sort-Object
|
||
|
|
||
|
if ($existingKeys) {
|
||
|
$nextValue = $existingKeys[-1] + 1
|
||
|
} else {
|
||
|
$nextValue = 1
|
||
|
}
|
||
|
|
||
|
# Adding the key to the registry
|
||
|
New-ItemProperty -Path $registryPath -Name $nextValue -Value $ExtensionID -PropertyType "String" -Force
|
||
|
|
||
|
Write-Host "Key added successfully under DWORD $nextValue."
|