Add Chrome homepage + startup tabs mirroring Edge config
Chrome (installed by PPKG) now gets the same profile-driven homepage and startup tabs as Edge. Uses HKLM:\SOFTWARE\Policies\Google\Chrome with the same policy keys (RestoreOnStartup, RestoreOnStartupURLs, HomepageLocation, HomepageIsNewTabPage, ShowHomeButton). Reuses the $startupTabs and $homepageUrl already resolved for Edge from the PC profile, so both browsers show identical tabs. Skips cleanly if Chrome isn't installed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -266,12 +266,56 @@ if ($startupTabs.Count -eq 0) {
|
|||||||
Write-Host "Homepage set to: $($startupTabs[0])"
|
Write-Host "Homepage set to: $($startupTabs[0])"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Chrome: same homepage + startup tabs as Edge
|
||||||
|
#
|
||||||
|
# The PPKG installs Chrome alongside Edge. Apply the same profile-driven
|
||||||
|
# homepage and startup tabs so both browsers behave identically. Uses the
|
||||||
|
# same $startupTabs and $homepageUrl resolved above.
|
||||||
|
# HKLM:\SOFTWARE\Policies\Google\Chrome mirrors the Edge policy structure.
|
||||||
|
# ============================================================================
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Configuring Chrome startup tabs..."
|
||||||
|
|
||||||
|
$chromePath = @(
|
||||||
|
'C:\Program Files\Google\Chrome\Application\chrome.exe',
|
||||||
|
'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
|
||||||
|
) | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
|
||||||
|
|
||||||
|
if (-not $chromePath) {
|
||||||
|
Write-Host " Chrome not installed - skipping." -ForegroundColor DarkGray
|
||||||
|
} elseif ($startupTabs.Count -eq 0) {
|
||||||
|
Write-Host " No startup tabs resolved - skipping Chrome config." -ForegroundColor DarkGray
|
||||||
|
} else {
|
||||||
|
$chromePolKey = 'HKLM:\SOFTWARE\Policies\Google\Chrome'
|
||||||
|
if (-not (Test-Path $chromePolKey)) {
|
||||||
|
New-Item -Path $chromePolKey -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
Set-ItemProperty -Path $chromePolKey -Name 'RestoreOnStartup' -Value 4 -Type DWord -Force
|
||||||
|
|
||||||
|
$urlsKey = Join-Path $chromePolKey 'RestoreOnStartupURLs'
|
||||||
|
if (Test-Path $urlsKey) {
|
||||||
|
Remove-Item -Path $urlsKey -Recurse -Force
|
||||||
|
}
|
||||||
|
New-Item -Path $urlsKey -Force | Out-Null
|
||||||
|
for ($i = 0; $i -lt $startupTabs.Count; $i++) {
|
||||||
|
Set-ItemProperty -Path $urlsKey -Name ([string]($i + 1)) -Value $startupTabs[$i] -Type String -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
$chromeHomepage = if ($homepageUrl) { $homepageUrl } elseif ($edgeHomepage) { $edgeHomepage } else { $startupTabs[0] }
|
||||||
|
Set-ItemProperty -Path $chromePolKey -Name 'HomepageLocation' -Value $chromeHomepage -Type String -Force
|
||||||
|
Set-ItemProperty -Path $chromePolKey -Name 'HomepageIsNewTabPage' -Value 0 -Type DWord -Force
|
||||||
|
Set-ItemProperty -Path $chromePolKey -Name 'ShowHomeButton' -Value 1 -Type DWord -Force
|
||||||
|
|
||||||
|
Write-Host " Chrome startup tabs set ($($startupTabs.Count) tab(s)), homepage: $chromeHomepage"
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "================================================================"
|
Write-Host "================================================================"
|
||||||
Write-Host "08-EdgeDefaultBrowser.ps1 complete."
|
Write-Host "08-EdgeDefaultBrowser.ps1 complete."
|
||||||
Write-Host "Effective for new user profiles on first logon (Azure AD users)."
|
Write-Host "Edge + Chrome homepage and startup tabs configured."
|
||||||
Write-Host "Existing profiles will pick up the startup-tab policy on next"
|
Write-Host "Machine-wide GPO - applies to all users on next browser launch."
|
||||||
Write-Host "Edge launch - it's a machine-wide GPO."
|
|
||||||
Write-Host "================================================================"
|
Write-Host "================================================================"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user