-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathUpdate-StoreIDs.ps1
More file actions
100 lines (84 loc) · 3.54 KB
/
Update-StoreIDs.ps1
File metadata and controls
100 lines (84 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Update Registry Files with Store Extension IDs
# Run this after getting extension IDs from stores
param(
[string]$ChromeExtensionId,
[string]$EdgeExtensionId,
[string]$FirefoxExtensionId
)
Write-Output "🔄 Updating registry files with store extension IDs..."
if (!$ChromeExtensionId -and !$EdgeExtensionId -and !$FirefoxExtensionId) {
Write-Output "❌ Please provide at least one extension ID"
Write-Output "Usage: .\Update-StoreIDs.ps1 -ChromeExtensionId 'abcd...' -EdgeExtensionId 'efgh...'"
exit 1
}
# Validate extension ID format
function Test-ExtensionId {
param($Id, $Store)
if ($Store -eq "Firefox" -and $Id -match "^\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}$") {
return $true # Firefox GUID format
}
if ($Id -match "^[a-z]{32}$") {
return $true # Chrome/Edge format
}
return $false
}
# Update Chrome registry
if ($ChromeExtensionId) {
if (Test-ExtensionId $ChromeExtensionId "Chrome") {
$chromeFile = "registry-chrome-store.reg"
if (Test-Path $chromeFile) {
$content = Get-Content $chromeFile -Raw
$content = $content -replace "CHROME_EXTENSION_ID", $ChromeExtensionId
$content | Set-Content $chromeFile -Encoding UTF8
Write-Output "✅ Updated Chrome registry: $chromeFile"
}
} else {
Write-Output "❌ Invalid Chrome extension ID format: $ChromeExtensionId"
}
}
# Update Edge registry
if ($EdgeExtensionId) {
if (Test-ExtensionId $EdgeExtensionId "Edge") {
$edgeFile = "registry-edge-store.reg"
if (Test-Path $edgeFile) {
$content = Get-Content $edgeFile -Raw
$content = $content -replace "EDGE_EXTENSION_ID", $EdgeExtensionId
$content | Set-Content $edgeFile -Encoding UTF8
Write-Output "✅ Updated Edge registry: $edgeFile"
}
} else {
Write-Output "❌ Invalid Edge extension ID format: $EdgeExtensionId"
}
}
# Update Firefox registry (if provided)
if ($FirefoxExtensionId) {
if (Test-ExtensionId $FirefoxExtensionId "Firefox") {
Write-Output "✅ Firefox extension ID validated: $FirefoxExtensionId"
# Firefox policies would go in a separate file
} else {
Write-Output "❌ Invalid Firefox extension ID format: $FirefoxExtensionId"
}
}
# Update documentation
$storeIdFile = "STORE_IDS.md"
if (Test-Path $storeIdFile) {
$content = Get-Content $storeIdFile -Raw
if ($ChromeExtensionId) {
$content = $content -replace 'CHROME_EXTENSION_ID="will-be-assigned-by-google"', "CHROME_EXTENSION_ID=`"$ChromeExtensionId`""
}
if ($EdgeExtensionId) {
$content = $content -replace 'EDGE_EXTENSION_ID="will-be-assigned-by-microsoft"', "EDGE_EXTENSION_ID=`"$EdgeExtensionId`""
}
if ($FirefoxExtensionId) {
$content = $content -replace 'FIREFOX_EXTENSION_ID="will-be-assigned-by-mozilla"', "FIREFOX_EXTENSION_ID=`"$FirefoxExtensionId`""
}
$content | Set-Content $storeIdFile -Encoding UTF8
Write-Output "✅ Updated store IDs documentation"
}
Write-Output ""
Write-Output "🎉 Registry files updated successfully!"
Write-Output "📋 Next steps:"
Write-Output "1. Import the updated registry files on test machines"
Write-Output "2. Install extensions from stores (will auto-install with force_installed)"
Write-Output "3. Verify managed policies are applied"
Write-Output "4. Deploy to production environments"