From 1e9c6ebc54d5455ac7dea7e08bebb0976c1cc61b Mon Sep 17 00:00:00 2001 From: zebra Date: Thu, 22 Feb 2024 22:12:04 -0800 Subject: [PATCH] Added extension installation scripts --- installExtension.ps1 | 44 ++++++++++++++++++++++++++++++++++++++++++++ installUblock.ps1 | 17 +++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 installExtension.ps1 create mode 100644 installUblock.ps1 diff --git a/installExtension.ps1 b/installExtension.ps1 new file mode 100644 index 0000000..9cdc78c --- /dev/null +++ b/installExtension.ps1 @@ -0,0 +1,44 @@ +#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." \ No newline at end of file diff --git a/installUblock.ps1 b/installUblock.ps1 new file mode 100644 index 0000000..f819006 --- /dev/null +++ b/installUblock.ps1 @@ -0,0 +1,17 @@ +#Zebra - 2/22/2024 +#Force installs uBlock Origin to Edge and Chrome. +#Delete regkeys to remove + +# Defining the web store extension IDs +$chromeKey = "cjpalhdlnbpafiamejdnhcphjbkeiagm" +$edgeKey = "odfafepnkmbhccpbejgmiehpchacaeak" + +# Defining the paths for each regkey +$chromePath = "HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist" +$edgePath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallForcelist" + +# Add the keys to the registry +New-ItemProperty -Path $chromePath -Name "1" -Value $chromeKey -PropertyType "String" -Force +New-ItemProperty -Path $edgePath -Name "1" -Value $edgeKey -PropertyType "String" -Force + +Write-Host "uBlock installed on Chrome and Edge successfully." \ No newline at end of file