Private/OSB-Scripts.ps1
function OSB-Scripts { [CmdletBinding()] PARAM () Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Task Scripts" -ForegroundColor Green if ($Scripts) { foreach ($Script in $Scripts) { if (Test-Path "$OSBuilderContent\$Script") { Write-Host "PowerShell Script: $OSBuilderContent\$Script" -ForegroundColor Green Invoke-Expression "& '$OSBuilderContent\$Script'" } } } else { Write-Host "No Task Scripts were processed" -ForegroundColor DarkGray } Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Template Scripts" -ForegroundColor Green $AOSBScripts = @() $AOSBScripts = Get-ChildItem ("$OSBuilderTemplates\Scripts\AutoApply\Global\*","$OSBuilderTemplates\Scripts\AutoApply\Global $OSArchitecture\*") *.ps1 | Select-Object -Property FullName if ($OSVersionNumber -eq 7601) { [array]$AOSBScripts += Get-ChildItem ("$OSBuilderTemplates\Scripts\AutoApply\Windows 7\*","$OSBuilderTemplates\Scripts\AutoApply\Windows 7 $OSArchitecture\*") *.ps1 | Select-Object -Property FullName } else { if ($OSInstallationType -eq 'Client') { [array]$AOSBScripts += Get-ChildItem ("$OSBuilderTemplates\Scripts\AutoApply\Windows 10\*","$OSBuilderTemplates\Scripts\AutoApply\Windows 10 $OSArchitecture\*") *.ps1 | Select-Object -Property FullName #[array]$AOSBScripts += Get-ChildItem ("$OSBuilderTemplates\Scripts\AutoApply\Windows 10\*","$OSBuilderTemplates\Scripts\AutoApply\Windows 10 $OSArchitecture\*","$OSBuilderTemplates\Scripts\AutoApply\Windows 10 $OSArchitecture $OSVersionNumber\*") *.ps1 | Select-Object -Property FullName } else { [array]$AOSBScripts += Get-ChildItem "$OSBuilderTemplates\Scripts\AutoApply\Windows Server\*" *.ps1 | Select-Object -Property FullName #[array]$AOSBScripts += Get-ChildItem ("$OSBuilderTemplates\Scripts\AutoApply\Windows Server\*","$OSBuilderTemplates\Scripts\AutoApply\Windows Server $OSVersionNumber\*") *.ps1 | Select-Object -Property FullName } } if ($SkipTemplates) {$AOSBScripts = @()} if ($AOSBScripts) { foreach ($Script in $AOSBScripts) { Write-Host "$($Script.FullName)" -ForegroundColor DarkGray if (Test-Path "$($Script.FullName)") { Write-Host "PowerShell Script: $($Script.FullName)" -ForegroundColor Green Invoke-Expression "& '$($Script.FullName)'" } } } else { Write-Host "No Template Scripts were processed" -ForegroundColor DarkGray } } |