Private/OSB-OSBuild.ps1
function OSB-OSBuild-EnableNetFX { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 OSBuild EnableNetFX3' #=================================================================================================== if ($OSMajorVersion -ne 10) {Return} Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Enable NetFX 3.5" -ForegroundColor Green Enable-WindowsOptionalFeature -Path "$MountDirectory" -FeatureName NetFX3 -All -LimitAccess -Source "$OS\sources\sxs" -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-NetFX3.log" | Out-Null } function OSB-OSBuild-FeaturesOnDemand { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Features On Demand' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Features On Demand" -ForegroundColor Green foreach ($FOD in $FeaturesOnDemand) { Write-Host $FOD -ForegroundColor DarkGray $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-FOD.log" Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$OSBuilderContent\$FOD" -LogPath "$CurrentLog" | Out-Null } } function OSB-OSBuild-RemoveAppx { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Remove Appx Packages' #=================================================================================================== if ($OSMajorVersion -ne 10) {Return} Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Remove Appx Packages" -ForegroundColor Green foreach ($item in $RemoveAppx) { Write-Host $item -ForegroundColor DarkGray Remove-AppxProvisionedPackage -Path "$MountDirectory" -PackageName $item -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Remove-AppxProvisionedPackage.log" | Out-Null } } function OSB-OSBuild-RemovePackage { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Remove Packages' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Remove Windows Packages" -ForegroundColor Green foreach ($PackageName in $RemovePackage) { Write-Host $item -ForegroundColor DarkGray Remove-WindowsPackage -Path "$MountDirectory" -PackageName $PackageName -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Remove-WindowsPackage.log" | Out-Null } } function OSB-OSBuild-RemoveCapability { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Remove Capability' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Remove Windows Capability" -ForegroundColor Green foreach ($Name in $RemoveCapability) { Write-Host $Name -ForegroundColor DarkGray Remove-WindowsCapability -Path "$MountDirectory" -Name $Name -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Remove-WindowsCapability.log" | Out-Null } } function OSB-OSBuild-EnableWindowsOptionalFeature { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Enable Windows Optional Features' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Enable Windows Optional Feature" -ForegroundColor Green foreach ($FeatureName in $EnableFeature) { Write-Host $FeatureName -ForegroundColor DarkGray Enable-WindowsOptionalFeature -FeatureName $FeatureName -Path "$MountDirectory" -All -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Enable-WindowsOptionalFeature.log" | Out-Null } } function OSB-OSBuild-DisableWindowsOptionalFeature { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Disable Windows Optional Feature' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Disable Windows Optional Feature" -ForegroundColor Green foreach ($FeatureName in $DisableFeature) { Write-Host $FeatureName -ForegroundColor DarkGray Disable-WindowsOptionalFeature -FeatureName $FeatureName -Path "$MountDirectory" -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Disable-WindowsOptionalFeature.log" | Out-Null } } function OSB-OSBuild-Packages { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Add Packages' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Add Packages" -ForegroundColor Green foreach ($PackagePath in $Packages) { Write-Host "$OSBuilderContent\$PackagePath" -ForegroundColor DarkGray Add-WindowsPackage -PackagePath "$OSBuilderContent\$PackagePath" -Path "$MountDirectory" -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-WindowsPackage.log" | Out-Null } } function OSB-OSBuild-Drivers { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Add Drivers' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Drivers" -ForegroundColor Green foreach ($Driver in $Drivers) { Write-Host "$OSBuilderContent\$Driver" -ForegroundColor DarkGray if ($OSMajorVersion -eq 6) { dism /Image:"$MountDirectory" /Add-Driver /Driver:"$OSBuilderContent\$Driver" /Recurse /ForceUnsigned /LogPath:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-DISM-Add-Driver.log" } else { Add-WindowsDriver -Driver "$OSBuilderContent\$Driver" -Recurse -Path "$MountDirectory" -ForceUnsigned -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-WindowsDriver.log" | Out-Null } } } function OSB-OSBuild-ExtraFiles { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Extra Files' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Extra Files" -ForegroundColor Green foreach ($ExtraFile in $ExtraFiles) { Write-Host "$OSBuilderContent\$ExtraFile" -ForegroundColor DarkGray robocopy "$OSBuilderContent\$ExtraFile" "$MountDirectory" *.* /e /ndl /xx /b /np /ts /tee /r:0 /w:0 /Log+:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ExtraFiles.log" | Out-Null } } function OSB-OSBuild-StartLayout { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Start Layout' #=================================================================================================== if ($OSMajorVersion -ne 10) {Return} Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Start Layout" -ForegroundColor Green Write-Host "$OSBuilderContent\$StartLayoutXML" -ForegroundColor DarkGray Copy-Item -Path "$OSBuilderContent\$StartLayoutXML" -Destination "$MountDirectory\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.xml" -Recurse -Force | Out-Null } function OSB-OSBuild-Unattend { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 Unattend.xml' #=================================================================================================== if ($OSMajorVersion -ne 10) {Return} Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Unattend.xml" -ForegroundColor Green Write-Host "$OSBuilderContent\$UnattendXML" -ForegroundColor DarkGray if (!(Test-Path "$MountDirectory\Windows\Panther")) {New-Item -Path "$MountDirectory\Windows\Panther" -ItemType Directory -Force | Out-Null} Copy-Item -Path "$OSBuilderContent\$UnattendXML" -Destination "$MountDirectory\Windows\Panther\Unattend.xml" -Force Use-WindowsUnattend -UnattendPath "$OSBuilderContent\$UnattendXML" -Path "$MountDirectory" -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Use-WindowsUnattend.log" | Out-Null } function OSB-OSBuild-Scripts { [CmdletBinding()] PARAM () #=================================================================================================== Write-Verbose '19.1.25 PowerShell Scripts' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: PowerShell Scripts" -ForegroundColor Green foreach ($PSScript in $Scripts) { if (Test-Path "$OSBuilderContent\$PSScript") { Write-Host "PowerShell Script: $OSBuilderContent\$PSScript" -ForegroundColor Green Invoke-Expression "& '$OSBuilderContent\$PSScript'" } } } |