2024-06-10 15:24:12 -05:00
|
|
|
param (
|
2026-05-19 20:40:02 +03:00
|
|
|
[switch]$Run
|
2024-06-10 15:24:12 -05:00
|
|
|
)
|
2024-09-10 03:21:50 +02:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
$OFS = "`r`n" # Makes it so we dont need to add -Raw to every Get-Content command
|
2024-06-10 15:24:12 -05:00
|
|
|
|
2024-02-21 16:06:27 -06:00
|
|
|
# Variable to sync between runspaces
|
|
|
|
|
$sync = [Hashtable]::Synchronized(@{})
|
|
|
|
|
$sync.configs = @{}
|
2023-03-07 12:28:00 -08:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
# Create the script in memory.
|
|
|
|
|
$script = [System.Collections.Generic.List[string]]::new()
|
2025-10-06 10:05:36 -05:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
$script.Add(
|
|
|
|
|
((Get-Content -Path scripts\start.ps1) -replace '#{replaceme}', (Get-Date -Format 'yy.MM.dd'))
|
2025-10-06 10:05:36 -05:00
|
|
|
)
|
|
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
$script.Add((Get-ChildItem -Path functions -Recurse -File | Get-Content))
|
2023-03-07 12:28:00 -08:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
Get-ChildItem config | ForEach-Object {
|
|
|
|
|
$obj = Get-Content -Path $_.FullName | ConvertFrom-Json
|
2024-06-29 00:59:38 +03:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
if ($_.Name -eq "applications.json") {
|
|
|
|
|
$fixed = [ordered]@{}
|
|
|
|
|
foreach ($p in $obj.PSObject.Properties) {
|
|
|
|
|
$fixed["WPFInstall$($p.Name)"] = $p.Value
|
2024-06-29 00:59:38 +03:00
|
|
|
}
|
2026-05-19 20:40:02 +03:00
|
|
|
$obj = [pscustomobject]$fixed
|
2024-06-29 00:59:38 +03:00
|
|
|
}
|
|
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
$json = $obj | ConvertTo-Json -Depth 10
|
2024-04-20 16:38:43 -05:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
$sync.configs[$_.BaseName] = $obj
|
|
|
|
|
$script.Add("`$sync.configs.$($_.BaseName) = @'`r`n$json`r`n'@ | ConvertFrom-Json")
|
2023-03-07 12:28:00 -08:00
|
|
|
}
|
|
|
|
|
|
2024-09-10 12:24:53 -07:00
|
|
|
# Read the entire XAML file as a single string, preserving line breaks
|
2026-05-19 20:40:02 +03:00
|
|
|
$xaml = Get-Content -Path xaml\inputXML.xaml
|
|
|
|
|
$script.Add('$inputXML = @''' + "`n" + $xaml + "`n" + '''@')
|
2024-03-21 16:58:40 -07:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
$autounattendXml = Get-Content -Path tools\autounattend.xml
|
|
|
|
|
$script.Add("`$WinUtilAutounattendXml = @'`r`n$autounattendXml`r`n'@")
|
2024-03-21 16:58:40 -07:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
$script.Add((Get-Content -Path scripts\main.ps1))
|
2024-06-10 15:24:12 -05:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
Set-Content -Path winutil.ps1 -Value $script
|
2024-08-07 15:24:26 -05:00
|
|
|
|
2026-05-19 20:40:02 +03:00
|
|
|
if ($Run) {
|
|
|
|
|
.\Winutil.ps1
|
2024-06-29 00:23:21 +03:00
|
|
|
}
|