New-OSBuildTask.ps1
function New-OSBuildTask { [CmdletBinding()] Param ( [Parameter(Mandatory)] [string]$TaskName, [string]$BuildName, [switch]$EnableNetFX3 ) #====================================================================================== # Validate Administrator Rights #====================================================================================== if (!([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` [Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Host "" Write-Host "OSBuilder: This function needs to be run as Administrator" -ForegroundColor Yellow Write-Host "" Return } #====================================================================================== # Initialize OSBuilder #====================================================================================== Get-OSBuilder -CreatePaths -HideDetails #====================================================================================== # Information #====================================================================================== $TaskName = "OSBuild $TaskName" $TaskPath = "$TasksPath\$TaskName.json" Write-Host "New OSBuild Task Settings" -ForegroundColor Yellow Write-Host "-Task Name: $TaskName" -ForegroundColor Cyan Write-Host "-Task Path: $TaskPath" -ForegroundColor Cyan Write-Host "-Build Name: $BuildName" -ForegroundColor Cyan Write-Host "-DotNet 3.5: $EnableNetFX3" -ForegroundColor Cyan Write-Host "" #====================================================================================== # Validate Task #====================================================================================== if (Test-Path $TaskPath) { Write-Warning "Task already exists at $TaskPath" Write-Warning "Content will be overwritten!" Write-Host "" } #====================================================================================== # Validate OSMedia has content #====================================================================================== $SelectedOSMedia = Get-ChildItem -Path "$OSMediaPath" -Directory | Where-Object {$_.Name -like "*.*"} | Select-Object -Property Name, FullName if ($null -eq $SelectedOSMedia) { Write-Warning "OSMedia content not found. Use Import-OSMedia to import an Operating System first . . . Exiting!" Break } #====================================================================================== # Validate OSMedia has an install.wim #====================================================================================== $SelectedOSMedia = $SelectedOSMedia | Where-Object {Test-Path $(Join-Path $_.FullName (Join-Path "OS" (Join-Path "sources" "install.wim")))} if ($null -eq $SelectedOSMedia) { Write-Warning "OSMedia Install.wim not found. Use Import-OSMedia to import an Operating System first . . . Exiting!" Break } #====================================================================================== # Validate OSMedia was imported with Import-OSMedia #====================================================================================== $SelectedOSMedia = $SelectedOSMedia | Where-Object {Test-Path $(Join-Path $_.FullName "WindowsImage.txt")} if ($null -eq $SelectedOSMedia) { Write-Warning "OSMedia content invalid (missing WindowsImage.txt). Use Import-OSMedia to import an Operating System first . . . Exiting!" Return } #====================================================================================== # Select Source OSMedia #====================================================================================== $SelectedOSMedia = $SelectedOSMedia | Out-GridView -Title "Select a Source OSMedia to use for this OSBuild Task (Cancel to Exit)" -OutputMode Single if($null -eq $SelectedOSMedia) { Write-Warning "Source OSMedia was not selected . . . Exiting!" Return } #====================================================================================== # Get Windows Image Information #====================================================================================== $OSSourcePath = "$($SelectedOSMedia.FullName)" $OSImagePath = "$OSSourcePath\OS\sources\install.wim" $OSImageIndex = 1 $WindowsImage = Get-WindowsImage -ImagePath "$OSImagePath" -Index $OSImageIndex | Select-Object -Property * $OSImageName = $($WindowsImage.ImageName) $OSImageDescription = $($WindowsImage.ImageDescription) if ($($WindowsImage.Architecture) -eq 0) {$OSArchitecture = 'x86'} elseif ($($WindowsImage.Architecture) -eq 1) {$OSArchitecture = 'MIPS'} elseif ($($WindowsImage.Architecture) -eq 2) {$OSArchitecture = 'Alpha'} elseif ($($WindowsImage.Architecture) -eq 3) {$OSArchitecture = 'PowerPC'} elseif ($($WindowsImage.Architecture) -eq 6) {$OSArchitecture = 'ia64'} elseif ($($WindowsImage.Architecture) -eq 9) {$OSArchitecture = 'x64'} else {$OSArchitecture = $null} $OSEditionID = $($WindowsImage.EditionId) $OSInstallationType = $($WindowsImage.InstallationType) $OSLanguages = $($WindowsImage.Languages) $OSBuild = $($WindowsImage.Build) $OSVersion = $($WindowsImage.Version) $OSSPBuild = $($WindowsImage.SPBuild) $OSSPLevel = $($WindowsImage.SPLevel) $OSImageBootable = $($WindowsImage.ImageBootable) $OSWIMBoot = $($WindowsImage.WIMBoot) $OSCreatedTime = $($WindowsImage.CreatedTime) $OSModifiedTime = $($WindowsImage.ModifiedTime) #====================================================================================== Write-Host "===========================================================================" -ForegroundColor Yellow Write-Host "OSMedia Information" -ForegroundColor Yellow Write-Host "===========================================================================" -ForegroundColor Yellow #====================================================================================== Write-Host "Source Path: $OSSourcePath" -ForegroundColor Yellow Write-Host "-Image File: $OSImagePath" -ForegroundColor Cyan Write-Host "-Image Index: $OSImageIndex" -ForegroundColor Cyan Write-Host "-Name: $OSImageName" -ForegroundColor Cyan Write-Host "-Description: $OSImageDescription" -ForegroundColor Cyan Write-Host "-Architecture: $OSArchitecture" -ForegroundColor Cyan Write-Host "-Edition: $OSEditionID" -ForegroundColor Cyan Write-Host "-Type: $OSInstallationType" -ForegroundColor Cyan Write-Host "-Languages: $OSLanguages" -ForegroundColor Cyan Write-Host "-Build: $OSBuild" -ForegroundColor Cyan Write-Host "-Version: $OSVersion" -ForegroundColor Cyan Write-Host "-SPBuild: $OSSPBuild" -ForegroundColor Cyan Write-Host "-SPLevel: $OSSPLevel" -ForegroundColor Cyan Write-Host "-Bootable: $OSImageBootable" -ForegroundColor Cyan Write-Host "-WimBoot: $OSWIMBoot" -ForegroundColor Cyan Write-Host "-Created Time: $OSCreatedTime" -ForegroundColor Cyan Write-Host "-Modified Time: $OSModifiedTime" -ForegroundColor Cyan Write-Host "" #====================================================================================== if (Test-Path "$OSSourcePath\info\xml\CurrentVersion.xml") { $RegCurrentVersion = Import-Clixml -Path "$OSSourcePath\info\xml\CurrentVersion.xml" $OSVersionNumber = $($RegCurrentVersion.ReleaseId) } else { if ($OSBuild -eq 17134) {$OSVersionNumber = 1803} if ($OSBuild -eq 16299) {$OSVersionNumber = 1709} if ($OSBuild -eq 15063) {$OSVersionNumber = 1703} if ($OSBuild -eq 14393) {$OSVersionNumber = 1607} if ($OSBuild -eq 10240) {$OSVersionNumber = 1507} } #====================================================================================== # Remove Provisioned Appx Package #====================================================================================== if ($OSImageName -notlike "*server*") { $RemoveAppxProvisionedPackage = Get-Content -Path "$OSSourcePath\info\json\Get-AppxProvisionedPackage.json" $RemoveAppxProvisionedPackage = $RemoveAppxProvisionedPackage | ConvertFrom-Json $RemoveAppxProvisionedPackage = $RemoveAppxProvisionedPackage | Select-Object -Property DisplayName, PackageName $RemoveAppxProvisionedPackage = $RemoveAppxProvisionedPackage | Out-GridView -Title "Select Windows InBox Apps to REMOVE and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $RemoveAppxProvisionedPackage) { Write-Warning "No InBox Windows App was selected to REMOVE" } } #====================================================================================== # Remove Windows Package #====================================================================================== #if ($ManageInBoxPackages) { $RemoveWindowsPackage = Get-Content -Path "$OSSourcePath\info\json\Get-WindowsPackage.json" $RemoveWindowsPackage = $RemoveWindowsPackage | ConvertFrom-Json $RemoveWindowsPackage = $RemoveWindowsPackage | Select-Object -Property PackageName $RemoveWindowsPackage = $RemoveWindowsPackage | Out-GridView -Title "Select Windows InBox Package to REMOVE and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $RemoveWindowsPackage) { Write-Warning "No InBox Windows Package was selected to REMOVE" } #} #====================================================================================== # Remove Windows Capability #====================================================================================== #if ($ManageInBoxCapabilities) { $RemoveWindowsCapability = Get-Content -Path "$OSSourcePath\info\json\Get-WindowsCapability.json" $RemoveWindowsCapability = $RemoveWindowsCapability | ConvertFrom-Json $RemoveWindowsCapability = $RemoveWindowsCapability | Select-Object -Property Name, State $RemoveWindowsCapability = $RemoveWindowsCapability | Out-GridView -Title "Select Windows InBox Capability to REMOVE and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $RemoveWindowsCapability) { Write-Warning "No InBox Windows Capability was selected to REMOVE" } #} #====================================================================================== # WindowsOptionalFeatures # https://docs.microsoft.com/en-us/powershell/module/dism/enable-windowsoptionalfeature?view=win10-ps # https://docs.microsoft.com/en-us/powershell/module/dism/disable-windowsoptionalfeature?view=win10-ps #====================================================================================== #if ($ManageInBoxFeatures) { $WindowsOptionalFeatures = Get-Content -Path "$OSSourcePath\info\json\Get-WindowsOptionalFeature.json" $WindowsOptionalFeatures = $WindowsOptionalFeatures | ConvertFrom-Json $DisableWindowsOptionalFeature = $WindowsOptionalFeatures | Select-Object -Property FeatureName, State | Sort-Object -Property FeatureName | Where-Object {$_.State -eq 2} $EnableWindowsOptionalFeature = $WindowsOptionalFeatures | Select-Object -Property FeatureName, State | Sort-Object -Property FeatureName | Where-Object {$_.State -eq 0} $DisableWindowsOptionalFeature = $DisableWindowsOptionalFeature | Select-Object -Property FeatureName $DisableWindowsOptionalFeature = $DisableWindowsOptionalFeature | Out-GridView -PassThru -Title "Select Enabled Windows Optional Features to DISABLE and press OK (Esc or Cancel to Skip)" if($null -eq $DisableWindowsOptionalFeature) { Write-Warning "No Enabled InBox Windows Optional Feature was selected to DISABLE" } $EnableWindowsOptionalFeature = $EnableWindowsOptionalFeature | Select-Object -Property FeatureName $EnableWindowsOptionalFeature = $EnableWindowsOptionalFeature | Out-GridView -PassThru -Title "Select Disabled Windows Optional Features to ENABLE and press OK (Esc or Cancel to Skip)" if($null -eq $EnableWindowsOptionalFeature) { Write-Warning "No Disabled InBox Windows Optional Feature was selected to ENABLE" } #} #====================================================================================== # Language Packs #====================================================================================== #if ($SelectLanguagePacks) { $SelectedLanguagePacks = Get-ChildItem -Path "$LanguagePacksPath" *.cab -Recurse | Select-Object -Property Name, FullName $SelectedLanguagePacks = $SelectedLanguagePacks | Where-Object {$_.FullName -like "*$OSArchitecture*"} if ($OSVersionNumber) {$SelectedLanguagePacks = $SelectedLanguagePacks | Where-Object {$_.FullName -like "*$OSVersionNumber*"}} if($null -eq $SelectedLanguagePacks) { Write-Warning "Language Packs: No compatible Language Packs were found in $LanguagePacksPath" } else { #if (@($SelectedLanguagePacks).Count -gt 0) { $SelectedLanguagePacks = $SelectedLanguagePacks | Out-GridView -Title "Language Packs: Select Language Packs to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedLanguagePacks) {Write-Warning "Skipping Language Packs"} #} } #} #====================================================================================== # Scripts #====================================================================================== $SelectedScripts = Get-ChildItem -Path "$ScriptsPath" *.ps1 | Select-Object -Property Name, FullName $SelectedScripts = $SelectedScripts | Out-GridView -Title "Select Install WIM PowerShell Scripts to execute and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedScripts) {Write-Warning "Skipping Install WIM PowerShell Scripts"} #====================================================================================== # Start Layout #====================================================================================== #if ($SelectStartLayout) { $SelectedStartLayoutXML = Get-ChildItem -Path "$StartLayoutsPath" *.xml | Select-Object -Property Name, FullName, Length, CreationTime | Sort-Object -Property FullName #$SelectedStartLayoutXML = $SelectedStartLayoutXML | ? {$_.FullName -like "*$OSArchitecture*"} $SelectedStartLayoutXML = $SelectedStartLayoutXML | Out-GridView -Title "Select a Start Layout XML to apply and press OK (Esc or Cancel to Skip)" -OutputMode Single if($null -eq $SelectedStartLayoutXML) {Write-Warning "Skipping Start Layout"} #} #====================================================================================== # Unattend.xml #====================================================================================== #if ($SelectUnattend) { $SelectedUnattendXML = Get-ChildItem -Path "$UnattendsPath" *.xml | Select-Object -Property Name, FullName, Length, CreationTime | Sort-Object -Property FullName #$SelectedUnattendXML = $SelectedUnattendXML | ? {$_.FullName -like "*$OSArchitecture*"} $SelectedUnattendXML = $SelectedUnattendXML | Out-GridView -Title "Select a Windows Unattend XML File to apply and press OK (Esc or Cancel to Skip)" -OutputMode Single if($null -eq $SelectedUnattendXML) {Write-Warning "Skipping Unattend.xml"} #} #====================================================================================== # Windows Drivers #====================================================================================== $SelectedDrivers = Get-ChildItem -Path "$DriversPath" -Directory | Select-Object -Property Name, FullName $SelectedDrivers = $SelectedDrivers | Out-GridView -Title "Select Driver Paths to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedDrivers) {Write-Warning "Skipping Drivers"} #====================================================================================== # Extra Files #====================================================================================== $SelectedExtraFiles = Get-ChildItem -Path "$ExtraFilesPath" -Directory | Select-Object -Property Name, FullName $SelectedExtraFiles = $SelectedExtraFiles | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} $SelectedExtraFiles = $SelectedExtraFiles | Out-GridView -Title "Select Extra Files to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedExtraFiles) {Write-Warning "Skipping Extra Files"} #====================================================================================== # Windows Packages #====================================================================================== $SelectedPackages = Get-ChildItem -Path "$PackagesPath" *.cab -Recurse | Select-Object -Property Name, FullName $SelectedPackages = $SelectedPackages | Where-Object {$_.FullName -like "*$OSArchitecture*"} $SelectedPackages = $SelectedPackages | Out-GridView -Title "Select Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedPackages) {Write-Warning "Skipping Packages"} #====================================================================================== # WinPE DaRT #====================================================================================== $SelectedWinPEDaRT = Get-ChildItem -Path "$Script:WinPEPath\DaRT" *.cab -Recurse | Select-Object -Property Name, FullName $SelectedWinPEDaRT = $SelectedWinPEDaRT | Where-Object {$_.FullName -like "*$OSArchitecture*"} $SelectedWinPEDaRT = $SelectedWinPEDaRT | Out-GridView -Title "Select a WinPE DaRT Package to apply and press OK (Esc or Cancel to Skip)" -OutputMode Single if($null -eq $SelectedWinPEDaRT) {Write-Warning "Skipping WinPE DaRT"} #====================================================================================== # WinPE Drivers #====================================================================================== $SelectedWinPEDrivers = Get-ChildItem -Path "$Script:WinPEPath\Drivers" -Directory | Select-Object -Property Name, FullName $SelectedWinPEDrivers = $SelectedWinPEDrivers | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} $SelectedWinPEDrivers = $SelectedWinPEDrivers | Out-GridView -Title "Select WinPE Drivers to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedWinPEDrivers) {Write-Warning "Skipping WinPE Drivers"} #====================================================================================== # Setup WIM Scripts #====================================================================================== $SelectedSetupWIMScripts = Get-ChildItem -Path "$Script:WinPEPath\Scripts" *.ps1 | Select-Object -Property Name, FullName $SelectedSetupWIMScripts = $SelectedSetupWIMScripts | Out-GridView -Title "Select Setup WIM PowerShell Scripts to execute and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedSetupWIMScripts) {Write-Warning "Skipping Setup WIM PowerShell Scripts"} #====================================================================================== # WinPE WIM Scripts #====================================================================================== $SelectedWinPEWIMScripts = Get-ChildItem -Path "$Script:WinPEPath\Scripts" *.ps1 | Select-Object -Property Name, FullName $SelectedWinPEWIMScripts = $SelectedWinPEWIMScripts | Out-GridView -Title "Select WinPE WIM PowerShell Scripts to execute and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedWinPEWIMScripts) {Write-Warning "Skipping WinPE WIM PowerShell Scripts"} #====================================================================================== # WinRE WIM Scripts #====================================================================================== $SelectedWinREWIMScripts = Get-ChildItem -Path "$Script:WinPEPath\Scripts" *.ps1 | Select-Object -Property Name, FullName $SelectedWinREWIMScripts = $SelectedWinREWIMScripts | Out-GridView -Title "Select WinRE WIM PowerShell Scripts to execute and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedWinREWIMScripts) {Write-Warning "Skipping WinRE WIM PowerShell Scripts"} #====================================================================================== # Setup WIM Extra Files #====================================================================================== $SelectedSetupWIMExtra = Get-ChildItem -Path "$Script:WinPEPath\ExtraFiles" -Directory | Select-Object -Property Name, FullName $SelectedSetupWIMExtra = $SelectedSetupWIMExtra | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} $SelectedSetupWIMExtra = $SelectedSetupWIMExtra | Out-GridView -Title "Select Setup WIM Extra Files to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedSetupWIMExtra) {Write-Warning "Skipping Setup WIM Extra Files"} #====================================================================================== # WinPE WIM Extra Files #====================================================================================== $SelectedWinPEWIMExtra = Get-ChildItem -Path "$Script:WinPEPath\ExtraFiles" -Directory | Select-Object -Property Name, FullName $SelectedWinPEWIMExtra = $SelectedWinPEWIMExtra | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} $SelectedWinPEWIMExtra = $SelectedWinPEWIMExtra | Out-GridView -Title "Select WinPE WIM Extra Files to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedWinPEWIMExtra) {Write-Warning "Skipping WinPE WIM Extra Files"} #====================================================================================== # WinRE WIM Extra Files #====================================================================================== $SelectedWinREWIMExtra = Get-ChildItem -Path "$Script:WinPEPath\ExtraFiles" -Directory | Select-Object -Property Name, FullName $SelectedWinREWIMExtra = $SelectedWinREWIMExtra | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} $SelectedWinREWIMExtra = $SelectedWinREWIMExtra | Out-GridView -Title "Select WinRE WIM Extra Files to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedWinREWIMExtra) {Write-Warning "Skipping WinRE WIM Extra Files"} #====================================================================================== # Setup WIM ADK Packages #====================================================================================== $SelectedSetupWIMADKPkgs = Get-ChildItem -Path "$Script:WinPEPath\ADK" *.cab -Recurse | Select-Object -Property Name, FullName $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.FullName -like "*$OSArchitecture*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.FullName -like "*$OSVersionNumber*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-EnhancedStorage*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Font*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-LegacySetup*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-SRT*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Scripting*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-SecureStartup*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Setup*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-WDS*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-WMI*"} $SelectedSetupWIMADKPkgs = $SelectedSetupWIMADKPkgs | Out-GridView -Title "Select Setup WIM ADK Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedSetupWIMADKPkgs) {Write-Warning "Skipping Setup WIM ADK Packages"} #====================================================================================== # WinPE WIM ADK Packages #====================================================================================== $SelectedWinPEWIMADKPkgs = Get-ChildItem -Path "$Script:WinPEPath\ADK" *.cab -Recurse | Select-Object -Property Name, FullName $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.FullName -like "*$OSArchitecture*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.FullName -like "*$OSVersionNumber*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-EnhancedStorage*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Font*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-LegacySetup*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-SRT*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Scripting*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-SecureStartup*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Setup*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-WDS*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-WMI*"} $SelectedWinPEWIMADKPkgs = $SelectedWinPEWIMADKPkgs | Out-GridView -Title "Select WinPE WIM ADK Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedWinPEWIMADKPkgs) {Write-Warning "Skipping WinPE WIM ADK Packages"} #====================================================================================== # WinRE WIM ADK Packages #====================================================================================== $SelectedWinREWIMADKPkgs = Get-ChildItem -Path "$Script:WinPEPath\ADK" *.cab -Recurse | Select-Object -Property Name, FullName $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.FullName -like "*$OSArchitecture*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.FullName -like "*$OSVersionNumber*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-EnhancedStorage*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-FMAPI*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Font*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-HTA*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-LegacySetup*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Rejuv*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-SRT*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Scripting*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-SecureStartup*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-Setup*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-StorageWMI*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-WDS*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Where-Object {$_.Name -notlike "WinPE-WMI*"} $SelectedWinREWIMADKPkgs = $SelectedWinREWIMADKPkgs | Out-GridView -Title "Select WinRE WIM ADK Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $SelectedWinREWIMADKPkgs) { Write-Warning "Skipping WinRE WIM ADK Packages" } else { Write-Warning "If you add too many ADK Packages to WinRE, like .Net and PowerShell" Write-Warning "You run a risk of your WinRE size increasing considerably" Write-Warning "If your MBR System or UEFI Recovery Partition are 500MB," Write-Warning "your WinRE.wim should not be more than 400MB (100MB Free)" Write-Warning "Consider changing your Task Sequences to have a 984MB" Write-Warning "MBR System or UEFI Recovery Partition" } #====================================================================================== # Build Task #====================================================================================== $Task = [ordered]@{ "TaskName" = [string]$TaskName; "TaskVersion" = [string]$($(Get-Module -Name OSBuilder).Version); "TaskType" = [string]"OSBuild"; "MediaName" = [string]$SelectedOSMedia.Name; "BuildName" = [string]$BuildName; #"WindowsUpdate" = [string]$SelectedUpdate.Name; "EnableNetFX3" = [string]$EnableNetFX3; "RemoveAppx" = [string[]]$RemoveAppxProvisionedPackage.PackageName; "RemovePackages" = [string[]]$RemoveWindowsPackage.PackageName; "RemoveCapability" = [string[]]$RemoveWindowsCapability.Name; "EnableFeature" = [string[]]$EnableWindowsOptionalFeature.FeatureName; "DisableFeature" = [string[]]$DisableWindowsOptionalFeature.FeatureName; "LanguagePacks" = [string[]]$SelectedLanguagePacks.FullName; "Drivers" = [string[]]$SelectedDrivers.Name; "ExtraFiles" = [string[]]$SelectedExtraFiles.FullName; "Scripts" = [string[]]$SelectedScripts.FullName; "Packages" = [string[]]$SelectedPackages.FullName; "StartLayout" = [string]$SelectedStartLayoutXML.FullName; "Unattend" = [string]$SelectedUnattendXML.FullName; "WinPEDaRT" = [string]$SelectedWinPEDaRT.FullName; "WinPEDrivers" = [string[]]$SelectedWinPEDrivers.Name; "SetupWimExtra" = [string[]]$SelectedSetupWIMExtra.FullName; "WinPEWimExtra" = [string[]]$SelectedWinPEWIMExtra.FullName; "WinREWimExtra" = [string[]]$SelectedWinREWIMExtra.FullName; "SetupWimScripts" = [string[]]$SelectedSetupWIMScripts.FullName; "WinPEWimScripts" = [string[]]$SelectedWinPEWIMScripts.FullName; "WinREWimScripts" = [string[]]$SelectedWinREWIMScripts.FullName; "SetupWimADK" = [string[]]$SelectedSetupWIMADKPkgs.FullName; "WinPEWimADK" = [string[]]$SelectedWinPEWIMADKPkgs.FullName; "WinREWimADK" = [string[]]$SelectedWinREWIMADKPkgs.FullName } #====================================================================================== Write-Host "===========================================================================" -ForegroundColor Green Write-Host "OSBuild Task: $TaskName" -ForegroundColor Green Write-Host "===========================================================================" -ForegroundColor Green #====================================================================================== $Task | ConvertTo-Json | Out-File "$TasksPath\$TaskName.json" $Task #====================================================================================== Write-Host "===========================================================================" -ForegroundColor Green Write-Host "Complete!" -ForegroundColor Green Write-Host "===========================================================================" -ForegroundColor Green #====================================================================================== } |