Extract site-specific values to site-config.json
New site-config.json file at C:\Enrollment\ (staged by startnet.cmd from
the enrollment share) contains all West Jefferson-specific values that were
previously hardcoded across 7 scripts. To deploy at a different GE site,
clone site-config.json and change the values - scripts need zero changes.
Config schema (v1.0):
siteName / siteNameCompact - UDC/eDNC site args
urls{} - Edge startup tab fallback URLs
edgeStartupTabs[] - ordered tab list with .url file basenames
opentext{} - excluded .hep profiles and .lnk shortcuts
startupItems[] - Configure-PC toggle list (exe/existing/url)
taskbarPins[] - 07-TaskbarLayout pin order with lnk paths
desktopApps[] - 06-OrganizeDesktop Phase 2 app list
Every script uses the same inline Get-SiteConfig helper that reads the
JSON and returns $null if missing/corrupt. All consumers fall back to the
current hardcoded West Jefferson defaults when $siteConfig is null, so
PXE servers without a site-config.json continue working identically.
Scripts updated:
06-OrganizeDesktop.ps1 - desktopApps array from config
07-TaskbarLayout.ps1 - pinSpec array from config
08-EdgeDefaultBrowser.ps1 - startup tab loop from config
Configure-PC.ps1 - startup items + site name from config
Check-MachineNumber.ps1 - site name from config
Set-MachineNumber.ps1 - site name from config
01-eDNC.ps1 - siteName + siteNameCompact from config
startnet.cmd - copies site-config.json from enrollment share
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,21 @@ if (-not $isAdmin) {
|
||||
exit 1
|
||||
}
|
||||
|
||||
function Get-SiteConfig {
|
||||
$configPath = 'C:\Enrollment\site-config.json'
|
||||
if (-not (Test-Path -LiteralPath $configPath)) {
|
||||
Write-Host "site-config.json not found - using defaults" -ForegroundColor DarkGray
|
||||
return $null
|
||||
}
|
||||
try {
|
||||
return (Get-Content -LiteralPath $configPath -Raw -ErrorAction Stop | ConvertFrom-Json)
|
||||
} catch {
|
||||
Write-Warning "Failed to parse site-config.json: $_"
|
||||
return $null
|
||||
}
|
||||
}
|
||||
$siteConfig = Get-SiteConfig
|
||||
|
||||
$publicDesktop = 'C:\Users\Public\Desktop'
|
||||
$shopfloorToolsDir = Join-Path $publicDesktop 'Shopfloor Tools'
|
||||
$defaultUserShell = 'C:\Users\Default\AppData\Local\Microsoft\Windows\Shell'
|
||||
@@ -42,40 +57,48 @@ $layoutXmlPath = Join-Path $defaultUserShell 'LayoutModification.xml'
|
||||
# it; all other entries reference C:\Users\Public\Desktop\Shopfloor Tools\
|
||||
# which 06-OrganizeDesktop.ps1 populates.
|
||||
# ============================================================================
|
||||
$pinSpec = @(
|
||||
@{
|
||||
Name = 'Microsoft Edge'
|
||||
Path = '%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk'
|
||||
# Resolved literal path used to check existence (can't Test-Path an
|
||||
# unexpanded env var reliably on older PS versions)
|
||||
Literal = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk'
|
||||
}
|
||||
@{
|
||||
Name = 'WJ Shopfloor'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\WJ Shopfloor.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'WJ Shopfloor.lnk')
|
||||
}
|
||||
@{
|
||||
Name = 'UDC'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\UDC.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'UDC.lnk')
|
||||
}
|
||||
@{
|
||||
Name = 'eDNC'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\eDNC.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'eDNC.lnk')
|
||||
}
|
||||
@{
|
||||
Name = 'NTLARS'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\NTLARS.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'NTLARS.lnk')
|
||||
}
|
||||
@{
|
||||
Name = 'Defect_Tracker'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\Defect_Tracker.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'Defect_Tracker.lnk')
|
||||
}
|
||||
)
|
||||
if ($siteConfig -and $siteConfig.taskbarPins) {
|
||||
$pinSpec = @($siteConfig.taskbarPins | ForEach-Object {
|
||||
@{
|
||||
Name = $_.name
|
||||
Path = $_.lnkPath
|
||||
Literal = [Environment]::ExpandEnvironmentVariables($_.lnkPath)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$pinSpec = @(
|
||||
@{
|
||||
Name = 'Microsoft Edge'
|
||||
Path = '%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk'
|
||||
Literal = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk'
|
||||
}
|
||||
@{
|
||||
Name = 'WJ Shopfloor'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\WJ Shopfloor.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'WJ Shopfloor.lnk')
|
||||
}
|
||||
@{
|
||||
Name = 'UDC'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\UDC.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'UDC.lnk')
|
||||
}
|
||||
@{
|
||||
Name = 'eDNC'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\eDNC.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'eDNC.lnk')
|
||||
}
|
||||
@{
|
||||
Name = 'NTLARS'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\NTLARS.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'NTLARS.lnk')
|
||||
}
|
||||
@{
|
||||
Name = 'Defect_Tracker'
|
||||
Path = '%PUBLIC%\Desktop\Shopfloor Tools\Defect_Tracker.lnk'
|
||||
Literal = (Join-Path $shopfloorToolsDir 'Defect_Tracker.lnk')
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Build the pin list - skip any whose .lnk is missing
|
||||
|
||||
Reference in New Issue
Block a user