Private/GetFunctions.ps1
function Get-FeatureUpdateDownloads { $FeatureUpdateDownloads = @() $FeatureUpdateDownloads = Get-OSDSUS FeatureUpdate <# $CatalogsXmls = @() $CatalogsXmls = Get-ChildItem "$($MyInvocation.MyCommand.Module.ModuleBase)\CatalogsESD\*" -Include *.xml foreach ($CatalogsXml in $CatalogsXmls) { $FeatureUpdateDownloads += Import-Clixml -Path "$($CatalogsXml.FullName)" } #> #=================================================================================================== # Get Downloadeds #=================================================================================================== foreach ($Download in $FeatureUpdateDownloads) { $FullUpdatePath = "$OSDBuilderPath\Media\$($Download.FileName)" if (Test-Path $FullUpdatePath) { $Download.OSDStatus = "Downloaded" } } #=================================================================================================== # Return #=================================================================================================== $FeatureUpdateDownloads = $FeatureUpdateDownloads | Select-Object -Property * | Sort-Object -Property CreationDate -Descending Return $FeatureUpdateDownloads } function Get-OSBuildTask { [CmdletBinding()] Param ( [switch]$GridView ) BEGIN { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) BEGIN" #=================================================================================================== Write-Verbose '19.1.1 Initialize OSDBuilder' #=================================================================================================== Get-OSDBuilder -CreatePaths -HideDetails #=================================================================================================== Write-Verbose '19.1.1 Gather All OSBuildTask' #=================================================================================================== $AllOSBuildTasks = @() $AllOSBuildTasks = Get-ChildItem -Path "$OSDBuilderTasks" OSBuild*.json -File | Select-Object -Property * } PROCESS { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) PROCESS" $OSBuildTask = foreach ($Item in $AllOSBuildTasks) { #=================================================================================================== #Write-Verbose '19.1.1 Get Windows Image Information' #=================================================================================================== $OSBuildTaskPath = $($Item.FullName) Write-Verbose "OSBuildTask Full Path: $OSBuildTaskPath" $OSBTask = @() $OSBTask = Get-Content "$($Item.FullName)" | ConvertFrom-Json $OSBTaskProps = @() $OSBTaskProps = Get-Item "$($Item.FullName)" | Select-Object -Property * if ([System.Version]$OSBTask.TaskVersion -lt [System.Version]"19.1.3.0") { $ObjectProperties = @{ LastWriteTime = $OSBTaskProps.LastWriteTime TaskName = $OSBTask.TaskName TaskVersion = $OSBTask.TaskVersion OSMediaName = $OSBTask.MediaName FullName = $Item.FullName } New-Object -TypeName PSObject -Property $ObjectProperties Write-Verbose "" } if ([System.Version]$OSBTask.TaskVersion -gt [System.Version]"19.1.3.0") { if ($null -eq $OSBTask.Languages) { Write-Warning "Reading Task: $OSBuildTaskPath" Write-Warning "Searching for OSMFamily: $($OSBTask.OSMFamily)" $LangUpdate = Get-OSMedia | Where-Object {$_.OSMFamilyV1 -eq $OSBTask.OSMFamily} | Select-Object -Last 1 Write-Warning "Adding Language: $($LangUpdate.Languages)" $OSBTask | Add-Member -Type NoteProperty -Name 'Languages' -Value "$LangUpdate.Languages" $OSBTask.Languages = $LangUpdate.Languages $OSBTask.OSMFamily = $OSBTask.InstallationType + " " + $OSBTask.EditionId + " " + $OSBTask.Arch + " " + [string]$OSBTask.Build + " " + $OSBTask.Languages Write-Warning "Updating OSMFamily: $($OSBTask.OSMFamily)" Write-Warning "Updating Task: $OSBuildTaskPath" $OSBTask | ConvertTo-Json | Out-File $OSBuildTaskPath Write-Host "" } $ObjectProperties = @{ TaskType = $OSBTask.TaskType TaskVersion = $OSBTask.TaskVersion TaskName = $OSBTask.TaskName TaskGuid = $OSBTask.TaskGuid CustomName = $OSBTask.CustomName SourceOSMedia = $OSBTask.Name ImageName = $OSBTask.ImageName Arch = $OSBTask.Arch ReleaseId = $OSBTask.ReleaseId UBR = $OSBTask.UBR Languages = $OSBTask.Languages EditionId = $OSBTask.EditionId FullName = $Item.FullName LastWriteTime = $OSBTaskProps.LastWriteTime CreatedTime = [datetime]$OSBTask.CreatedTime ModifiedTime = [datetime]$OSBTask.ModifiedTime OSMFamily = $OSBTask.OSMFamily OSMGuid = $OSBTask.OSMGuid } New-Object -TypeName PSObject -Property $ObjectProperties Write-Verbose "" } } #=================================================================================================== #Write-Verbose '19.1.3 Output' #=================================================================================================== if ($GridView.IsPresent) {$OSBuildTask | Select-Object TaskType,TaskVersion,TaskName,CustomName,SourceOSMedia,ImageName,Arch,ReleaseId,UBR,Languages,EditionId,FullName,LastWriteTime,OSMFamily,OSMGuid | Sort-Object TaskName | Out-GridView -PassThru -Title 'OSBuildTask'} else {$OSBuildTask | Select-Object TaskType,TaskVersion,TaskName,CustomName,SourceOSMedia,ImageName,Arch,ReleaseId,UBR,Languages,EditionId,FullName,LastWriteTime,OSMFamily,OSMGuid | Sort-Object TaskName } } END { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) END" } } function Get-OSDBuilderVersion { param ( [Parameter(Position=1)] [switch]$HideDetails ) $global:OSDBuilderVersion = $(Get-Module -Name OSDBuilder).Version if ($HideDetails -eq $false) { Write-Host "OSDBuilder $OSDBuilderVersion" Write-Host "" } } function Get-OSDUpdateDownloads { [CmdletBinding()] Param ( [string]$OSDGuid, [string]$UpdateTitle, [switch]$Silent ) #=================================================================================================== # Filtering #=================================================================================================== if ($OSDGuid) { $OSDUpdateDownload = Get-OSDUpdates -Silent | Where-Object {$_.OSDGuid -eq $OSDGuid} } elseif ($UpdateTitle) { $OSDUpdateDownload = Get-OSDUpdates -Silent | Where-Object {$_.UpdateTitle -eq $UpdateTitle} } else { Break } #=================================================================================================== # Download #=================================================================================================== foreach ($Update in $OSDUpdateDownload) { $DownloadPath = "$OSDBuilderPath\Content\OSDUpdate\$($Update.Catalog)\$($Update.Title)" $DownloadFullPath = "$DownloadPath\$($Update.FileName)" if (!(Test-Path $DownloadPath)) {New-Item -Path "$DownloadPath" -ItemType Directory -Force | Out-Null} if (!(Test-Path $DownloadFullPath)) { Write-Host "$DownloadFullPath" Write-Host "$($Update.OriginUri)" -ForegroundColor Gray $WebClient = New-Object System.Net.WebClient $WebClient.DownloadFile("$($Update.OriginUri)","$DownloadFullPath") #Start-BitsTransfer -Source $Update.OriginUri -Destination $DownloadFullPath } } } function Get-OSDUpdates { Param ( [switch]$Silent ) $AllOSDUpdates = @() if ($Silent.IsPresent) { $AllOSDUpdates = Get-OSDSUS Windows -Silent } else { $AllOSDUpdates = Get-OSDSUS Windows } Write-Verbose "" <# $CatalogsXmls = @() $CatalogsXmls = Get-ChildItem "$($MyInvocation.MyCommand.Module.ModuleBase)\Catalogs\*" -Include *.xml foreach ($CatalogsXml in $CatalogsXmls) { $AllOSDUpdates += Import-Clixml -Path "$($CatalogsXml.FullName)" } #> #=================================================================================================== # Standard Filters #=================================================================================================== <# $AllOSDUpdates = $AllOSDUpdates | Where-Object {$_.FileName -notlike "*.exe"} $AllOSDUpdates = $AllOSDUpdates | Where-Object {$_.FileName -notlike "*.psf"} $AllOSDUpdates = $AllOSDUpdates | Where-Object {$_.FileName -notlike "*.txt"} $AllOSDUpdates = $AllOSDUpdates | Where-Object {$_.FileName -notlike "*delta.exe"} $AllOSDUpdates = $AllOSDUpdates | Where-Object {$_.FileName -notlike "*express.cab"} $AllOSDUpdates = $AllOSDUpdates | Where-Object {$_.Title -notlike "* Next *"} #> #=================================================================================================== # Get Downloaded Updates #=================================================================================================== foreach ($Update in $AllOSDUpdates) { $FullUpdatePath = "$OSDBuilderPath\Content\OSDUpdate\$($Update.Catalog)\$($Update.Title)\$($Update.FileName)" if (Test-Path $FullUpdatePath) { $Update.OSDStatus = "Downloaded" } } #=================================================================================================== # Return #=================================================================================================== $AllOSDUpdates = $AllOSDUpdates | Select-Object -Property * Return $AllOSDUpdates } function Get-OSTemplateDrivers { [CmdletBinding()] Param () $DriverTemplates = @() Write-Host "$OSDBuilderTemplates\Drivers\AutoApply\Global" -ForegroundColor Gray [array]$DriverTemplates = Get-Item "$OSDBuilderTemplates\Drivers\AutoApply\Global" Write-Host "$OSDBuilderTemplates\Drivers\AutoApply\Global $OSArchitecture" -ForegroundColor Gray [array]$DriverTemplates += Get-Item "$OSDBuilderTemplates\Drivers\AutoApply\Global $OSArchitecture" Write-Host "$OSDBuilderTemplates\Drivers\AutoApply\$UpdateOS" -ForegroundColor Gray [array]$DriverTemplates += Get-Item "$OSDBuilderTemplates\Drivers\AutoApply\$UpdateOS" if ($OSInstallationType -notlike "*Server*") { Write-Host "$OSDBuilderTemplates\Drivers\AutoApply\$UpdateOS $OSArchitecture" -ForegroundColor Gray [array]$DriverTemplates += Get-Item "$OSDBuilderTemplates\Drivers\AutoApply\$UpdateOS $OSArchitecture" } if ($OSInstallationType -notlike "*Server*" -and $OSMajorVersion -eq 10) { Write-Host "$OSDBuilderTemplates\Drivers\AutoApply\$UpdateOS $OSArchitecture $ReleaseId" -ForegroundColor Gray [array]$DriverTemplates += Get-Item "$OSDBuilderTemplates\Drivers\AutoApply\$UpdateOS $OSArchitecture $ReleaseId" } Return $DriverTemplates } function Get-OSTemplateExtraFiles { [CmdletBinding()] Param () $ExtraFilesTemplates = @() Write-Host "$OSDBuilderTemplates\ExtraFiles\AutoApply\Global" -ForegroundColor DarkGray [array]$ExtraFilesTemplates = Get-ChildItem "$OSDBuilderTemplates\ExtraFiles\AutoApply\Global" | Where-Object {$_.PSIsContainer -eq $true} Write-Host "$OSDBuilderTemplates\ExtraFiles\AutoApply\Global $OSArchitecture" -ForegroundColor DarkGray [array]$ExtraFilesTemplates += Get-ChildItem "$OSDBuilderTemplates\ExtraFiles\AutoApply\Global $OSArchitecture" | Where-Object {$_.PSIsContainer -eq $true} Write-Host "$OSDBuilderTemplates\ExtraFiles\AutoApply\$UpdateOS" -ForegroundColor DarkGray [array]$ExtraFilesTemplates += Get-ChildItem "$OSDBuilderTemplates\ExtraFiles\AutoApply\$UpdateOS" | Where-Object {$_.PSIsContainer -eq $true} if ($OSInstallationType -notlike "*Server*") { Write-Host "$OSDBuilderTemplates\ExtraFiles\AutoApply\$UpdateOS $OSArchitecture" -ForegroundColor DarkGray [array]$ExtraFilesTemplates += Get-ChildItem "$OSDBuilderTemplates\ExtraFiles\AutoApply\$UpdateOS $OSArchitecture" | Where-Object {$_.PSIsContainer -eq $true} } if ($OSInstallationType -notlike "*Server*" -and $OSMajorVersion -eq 10) { Write-Host "$OSDBuilderTemplates\ExtraFiles\AutoApply\$UpdateOS $OSArchitecture $ReleaseId" -ForegroundColor DarkGray [array]$ExtraFilesTemplates += Get-ChildItem "$OSDBuilderTemplates\ExtraFiles\AutoApply\$UpdateOS $OSArchitecture $ReleaseId" | Where-Object {$_.PSIsContainer -eq $true} } Return $ExtraFilesTemplates } function Get-OSTemplateRegistryReg { [CmdletBinding()] Param () $RegistryTemplatesRegOriginal = @() $RegistryTemplatesRegOriginal = Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply" *.reg -Recurse | Select-Object -Property Name, BaseName, Extension, Directory, FullName foreach ($REG in $RegistryTemplatesRegOriginal) { if (!(Test-Path "$($REG.FullName).Offline")) { Write-Host "Creating $($REG.FullName).Offline" -ForegroundColor DarkGray $REGContent = Get-Content -Path $REG.FullName $REGContent = $REGContent -replace 'HKEY_CURRENT_USER','HKEY_LOCAL_MACHINE\OfflineDefaultUser' $REGContent = $REGContent -replace 'HKEY_LOCAL_MACHINE\\SOFTWARE','HKEY_LOCAL_MACHINE\OfflineSoftware' $REGContent = $REGContent -replace 'HKEY_LOCAL_MACHINE\\SYSTEM','HKEY_LOCAL_MACHINE\OfflineSystem' $REGContent = $REGContent -replace 'HKEY_USERS\\.DEFAULT','HKEY_LOCAL_MACHINE\OfflineDefault' $REGContent | Set-Content "$($REG.FullName).Offline" -Force } } $RegistryTemplatesReg = @() Write-Host "$OSDBuilderTemplates\Registry\AutoApply\Global" -ForegroundColor DarkGray [array]$RegistryTemplatesReg = Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\Global\*" *.reg.Offline -Recurse Write-Host "$OSDBuilderTemplates\Registry\AutoApply\Global $OSArchitecture" -ForegroundColor DarkGray [array]$RegistryTemplatesReg += Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\Global $OSArchitecture\*" *.reg.Offline -Recurse Write-Host "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS" -ForegroundColor DarkGray [array]$RegistryTemplatesReg += Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS\*" *.reg.Offline -Recurse if ($OSInstallationType -notlike "*Server*") { Write-Host "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS $OSArchitecture" -ForegroundColor DarkGray [array]$RegistryTemplatesReg += Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS $OSArchitecture\*" *.reg.Offline -Recurse } if ($OSInstallationType -notlike "*Server*" -and $OSMajorVersion -eq 10) { Write-Host "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS $OSArchitecture $ReleaseId" -ForegroundColor DarkGray [array]$RegistryTemplatesReg += Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS $OSArchitecture $ReleaseId\*" *.reg.Offline -Recurse } Return $RegistryTemplatesReg } function Get-OSTemplateRegistryXml { [CmdletBinding()] Param () $RegistryTemplatesXml = @() Write-Host "$OSDBuilderTemplates\Registry\AutoApply\Global" -ForegroundColor DarkGray [array]$RegistryTemplatesXml = Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\Global\*" *.xml -Recurse Write-Host "$OSDBuilderTemplates\Registry\AutoApply\Global $OSArchitecture" -ForegroundColor DarkGray [array]$RegistryTemplatesXml += Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\Global $OSArchitecture\*" *.xml -Recurse Write-Host "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS" -ForegroundColor DarkGray [array]$RegistryTemplatesXml += Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS\*" *.xml -Recurse if ($OSInstallationType -notlike "*Server*") { Write-Host "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS $OSArchitecture" -ForegroundColor DarkGray [array]$RegistryTemplatesXml += Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS $OSArchitecture\*" *.xml -Recurse } if ($OSInstallationType -notlike "*Server*" -and $OSMajorVersion -eq 10) { Write-Host "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS $OSArchitecture $ReleaseId" -ForegroundColor DarkGray [array]$RegistryTemplatesXml += Get-ChildItem "$OSDBuilderTemplates\Registry\AutoApply\$UpdateOS $OSArchitecture $ReleaseId\*" *.xml -Recurse } Return $RegistryTemplatesXml } function Get-OSTemplateScripts { [CmdletBinding()] Param () $ScriptTemplates = @() Write-Host "$OSDBuilderTemplates\Scripts\AutoApply\Global" -ForegroundColor DarkGray [array]$ScriptTemplates = Get-ChildItem "$OSDBuilderTemplates\Scripts\AutoApply\Global\*" *.ps1 -Recurse Write-Host "$OSDBuilderTemplates\Scripts\AutoApply\Global $OSArchitecture" -ForegroundColor DarkGray [array]$ScriptTemplates += Get-ChildItem "$OSDBuilderTemplates\Scripts\AutoApply\Global $OSArchitecture\*" *.ps1 -Recurse Write-Host "$OSDBuilderTemplates\Scripts\AutoApply\$UpdateOS" -ForegroundColor DarkGray [array]$ScriptTemplates += Get-ChildItem "$OSDBuilderTemplates\Scripts\AutoApply\$UpdateOS\*" *.ps1 -Recurse if ($OSInstallationType -notlike "*Server*") { Write-Host "$OSDBuilderTemplates\Scripts\AutoApply\$UpdateOS $OSArchitecture" -ForegroundColor DarkGray [array]$ScriptTemplates += Get-ChildItem "$OSDBuilderTemplates\Scripts\AutoApply\$UpdateOS $OSArchitecture\*" *.ps1 -Recurse } if ($OSInstallationType -notlike "*Server*" -and $OSMajorVersion -eq 10) { Write-Host "$OSDBuilderTemplates\Scripts\AutoApply\$UpdateOS $OSArchitecture $ReleaseId" -ForegroundColor DarkGray [array]$ScriptTemplates += Get-ChildItem "$OSDBuilderTemplates\Scripts\AutoApply\$UpdateOS $OSArchitecture $ReleaseId\*" *.ps1 -Recurse } Return $ScriptTemplates } function Get-PEBuildTask { [CmdletBinding()] Param ( [switch]$GridView ) BEGIN { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) BEGIN" #=================================================================================================== Write-Verbose '19.1.1 Initialize OSDBuilder' #=================================================================================================== Get-OSDBuilder -CreatePaths -HideDetails #=================================================================================================== Write-Verbose '19.1.1 Gather All PEBuildTask' #=================================================================================================== $AllPEBuildTasks = @() $AllPEBuildTasks = Get-ChildItem -Path "$OSDBuilderTasks" *.json -File | Select-Object -Property * $AllPEBuildTasks = $AllPEBuildTasks | Where-Object {$_.Name -like "MDT*" -or $_.Name -like "Recovery*" -or $_.Name -like "WinPE*"} } PROCESS { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) PROCESS" $PEBuildTask = foreach ($Item in $AllPEBuildTasks) { #=================================================================================================== #Write-Verbose '19.1.1 Get Windows Image Information' #=================================================================================================== $PEBuildTaskPath = $($Item.FullName) Write-Verbose "PEBuildTask Full Path: $PEBuildTaskPath" $PEBTask = @() $PEBTask = Get-Content "$($Item.FullName)" | ConvertFrom-Json $PEBTaskProps = @() $PEBTaskProps = Get-Item "$($Item.FullName)" | Select-Object -Property * if ([System.Version]$PEBTask.TaskVersion -lt [System.Version]"19.1.3.0") { $ObjectProperties = @{ LastWriteTime = $PEBTaskProps.LastWriteTime TaskName = $PEBTask.TaskName TaskVersion = $PEBTask.TaskVersion Name = $PEBTask.MediaName FullName = $Item.FullName } New-Object -TypeName PSObject -Property $ObjectProperties Write-Verbose "" } if ([System.Version]$PEBTask.TaskVersion -gt [System.Version]"19.1.3.0") { if ($null -eq $PEBTask.Languages) { Write-Warning "Reading Task: $PEBuildTaskPath" Write-Warning "Searching for OSMFamily: $($PEBTask.OSMFamily)" $LangUpdate = Get-OSMedia | Where-Object {$_.OSMFamilyV1 -eq $PEBTask.OSMFamily} | Select-Object -Last 1 Write-Warning "Adding Language: $($LangUpdate.Languages)" $PEBTask | Add-Member -Type NoteProperty -Name 'Languages' -Value "$LangUpdate.Languages" $PEBTask.Languages = $LangUpdate.Languages $PEBTask.OSMFamily = $PEBTask.InstallationType + " " + $PEBTask.EditionId + " " + $PEBTask.Arch + " " + [string]$PEBTask.Build + " " + $PEBTask.Languages Write-Warning "Updating OSMFamily: $($PEBTask.OSMFamily)" Write-Warning "Updating Task: $PEBuildTaskPath" $PEBTask | ConvertTo-Json | Out-File $PEBuildTaskPath Write-Host "" } $ObjectProperties = @{ TaskType = $PEBTask.TaskType TaskVersion = $PEBTask.TaskVersion TaskName = $PEBTask.TaskName TaskGuid = $PEBTask.TaskGuid CustomName = $PEBTask.CustomName SourceOSMedia = $PEBTask.Name ImageName = $PEBTask.ImageName Arch = $PEBTask.Arch ReleaseId = $PEBTask.ReleaseId UBR = $PEBTask.UBR EditionId = $PEBTask.EditionId FullName = $Item.FullName LastWriteTime = $PEBTaskProps.LastWriteTime CreatedTime = [datetime]$PEBTask.CreatedTime ModifiedTime = [datetime]$PEBTask.ModifiedTime OSMFamily = $PEBTask.OSMFamily OSMGuid = $PEBTask.OSMGuid } New-Object -TypeName PSObject -Property $ObjectProperties Write-Verbose "" } } #=================================================================================================== #Write-Verbose '19.1.3 Output' #=================================================================================================== if ($GridView.IsPresent) {$PEBuildTask | Select-Object TaskType,TaskVersion,TaskName,CustomName,SourceOSMedia,ImageName,Arch,ReleaseId,UBR,EditionId,FullName,LastWriteTime,OSMFamily,OSMGuid | Sort-Object TaskName | Out-GridView -PassThru -Title 'PEBuildTask'} else {$PEBuildTask | Select-Object TaskType,TaskVersion,TaskName,CustomName,SourceOSMedia,ImageName,Arch,ReleaseId,UBR,EditionId,FullName,LastWriteTime,OSMFamily,OSMGuid | Sort-Object TaskName } } END { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) END" } } function Get-TaskContentAddFeatureOnDemand { #=================================================================================================== # Install.Wim Features On Demand #=================================================================================================== [CmdletBinding()] Param () $FeaturesOnDemandIsoExtractDir =@() $FeaturesOnDemandIsoExtractDir = $ContentIsoExtract if ($OSMedia.InstallationType -eq 'Client') { if ($($OSMedia.Arch) -eq 'x64') {$FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.FullName -like "*x64*"}} if ($($OSMedia.Arch) -eq 'x86') {$FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.FullName -like "*x86*"}} } $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*lp.cab"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*Language-Pack*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*Language-Interface-Pack*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*LanguageFeatures*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*LanguageExperiencePack*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.FullName -notlike "*metadata*"} if ($OSMedia.ReleaseId -gt 1803) { $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*ActiveDirectory*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*BitLocker-Recovery*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*CertificateServices*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*DHCP-Tools*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*DNS-Tools*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*FailoverCluster*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*FileServices-Tools*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*GroupPolicy-Management*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*IPAM-Client*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*LLDP*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*NetworkController*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*NetworkLoadBalancing*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*RasCMAK*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*RasRip*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*RemoteAccess-Management*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*RemoteDesktop-Services*"} #$FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*Server-AppCompat*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*ServerManager-Tools*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*Shielded-VM*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*SNMP-Client*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*StorageManagement*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*StorageMigrationService*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*StorageReplica*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*SystemInsights*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*VolumeActivation*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*WMI-SNMP-Provider*"} $FeaturesOnDemandIsoExtractDir = $FeaturesOnDemandIsoExtractDir | Where-Object {$_.Name -notlike "*WSUS-Tools*"} } $FeaturesOnDemandUpdatesDir = @() if (Test-Path "$OSDBuilderContent\Updates\FeatureOnDemand") { $FeaturesOnDemandUpdatesDir = Get-ChildItem -Path "$OSDBuilderContent\Updates\FeatureOnDemand" *.cab -Recurse | Select-Object -Property Name, FullName } $AddFeatureOnDemand = [array]$FeaturesOnDemandIsoExtractDir + [array]$FeaturesOnDemandUpdatesDir if ($OSMedia.InstallationType -eq 'Client') {$AddFeatureOnDemand = $AddFeatureOnDemand | Where-Object {$_.FullName -notlike "*Windows Server*"}} if ($OSMedia.InstallationType -like "*Server*") {$AddFeatureOnDemand = $AddFeatureOnDemand | Where-Object {$_.FullName -like "*Windows Server*"}} if ($($OSMedia.ReleaseId)) { if ($($OSMedia.ReleaseId) -eq 1909) { $AddFeatureOnDemand = $AddFeatureOnDemand | Where-Object {$_.FullName -match '1903' -or $_.FullName -match '1909'} } else { $AddFeatureOnDemand = $AddFeatureOnDemand | Where-Object {$_.FullName -like "*$($OSMedia.ReleaseId)*"} } } foreach ($Pack in $AddFeatureOnDemand) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $AddFeatureOnDemand) {Write-Warning "Install.wim Features On Demand: Not Found"} else { if ($ExistingTask.AddFeatureOnDemand) { foreach ($Item in $ExistingTask.AddFeatureOnDemand) { $AddFeatureOnDemand = $AddFeatureOnDemand | Where-Object {$_.FullName -ne $Item} } } $AddFeatureOnDemand = $AddFeatureOnDemand | Sort-Object -Property FullName | Out-GridView -Title "Install.wim Features On Demand: Select Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $AddFeatureOnDemand) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $AddFeatureOnDemand } function Get-TaskContentAddWindowsPackage { #=================================================================================================== # Content Packages #=================================================================================================== [CmdletBinding()] Param () $AddWindowsPackage = Get-ChildItem -Path "$OSDBuilderContent\Packages\*" -Include *.cab, *.msu -Recurse | Select-Object -Property Name, FullName $AddWindowsPackage = $AddWindowsPackage | Where-Object {$_.FullName -like "*$($OSMedia.Arch)*"} foreach ($Item in $AddWindowsPackage) {$Item.FullName = $($Item.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $AddWindowsPackage) {Write-Warning "Packages: To select Windows Packages, add Content to $OSDBuilderContent\Packages"} else { if ($ExistingTask.AddWindowsPackage) { foreach ($Item in $ExistingTask.AddWindowsPackage) { $AddWindowsPackage = $AddWindowsPackage | Where-Object {$_.FullName -ne $Item} } } $AddWindowsPackage = $AddWindowsPackage | Out-GridView -Title "Packages: Select Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $AddWindowsPackage) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $AddWindowsPackage } function Get-TaskContentDrivers { #=================================================================================================== # Content Drivers #=================================================================================================== [CmdletBinding()] Param () $Drivers = Get-ChildItem -Path "$OSDBuilderContent\Drivers" -Directory -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName foreach ($Pack in $Drivers) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $Drivers) {Write-Warning "Drivers: To select Windows Drivers, add Content to $OSDBuilderContent\Drivers"} else { if ($ExistingTask.Drivers) { foreach ($Item in $ExistingTask.Drivers) { $Drivers = $Drivers | Where-Object {$_.FullName -ne $Item} } } $Drivers = $Drivers | Out-GridView -Title "Drivers: Select Driver Paths to apply and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $Drivers) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $Drivers } function Get-TaskContentExtraFiles { #=================================================================================================== # Content ExtraFiles #=================================================================================================== [CmdletBinding()] Param () $ExtraFiles = Get-ChildItem -Path "$OSDBuilderContent\ExtraFiles" -Directory -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName $ExtraFiles = $ExtraFiles | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} foreach ($Pack in $ExtraFiles) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $ExtraFiles) {Write-Warning "Extra Files: To select Extra Files, add Content to $OSDBuilderContent\ExtraFiles"} else { if ($ExistingTask.ExtraFiles) { foreach ($Item in $ExistingTask.ExtraFiles) { $ExtraFiles = $ExtraFiles | Where-Object {$_.FullName -ne $Item} } } $ExtraFiles = $ExtraFiles | Out-GridView -Title "Extra Files: Select directories to inject and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $ExtraFiles) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $ExtraFiles } function Get-TaskContentIsoExtract { [CmdletBinding()] Param () $ContentIsoExtract = Get-ChildItem -Path "$OSDBuilderContent\IsoExtract\*" -Include *.cab, *.appx -Recurse | Select-Object -Property Name, FullName if ($($OSMedia.ReleaseId)) { if ($($OSMedia.ReleaseId) -eq 1909) { $AddFeatureOnDemand = $AddFeatureOnDemand | Where-Object {$_.FullName -match '1903' -or $_.FullName -match '1909'} } else { $ContentIsoExtract = $ContentIsoExtract | Where-Object {$_.FullName -like "*$($OSMedia.ReleaseId)*"} } } foreach ($IsoExtractPackage in $ContentIsoExtract) {$IsoExtractPackage.FullName = $($IsoExtractPackage.FullName).replace("$OSDBuilderContent\",'')} $ContentIsoExtract = $ContentIsoExtract | Where-Object {$_.FullName -notlike "*\arm64\*"} if ($($OSMedia.Arch) -eq 'x64') {$ContentIsoExtract = $ContentIsoExtract | Where-Object {$_.Name -notlike "*x86*"}} if ($($OSMedia.Arch) -eq 'x64') {$ContentIsoExtract = $ContentIsoExtract | Where-Object {$_.FullName -notlike "*\x86\*"}} if ($($OSMedia.Arch) -eq 'x86') {$ContentIsoExtract = $ContentIsoExtract | Where-Object {$_.Name -notlike "*x64*"}} if ($($OSMedia.Arch) -eq 'x86') {$ContentIsoExtract = $ContentIsoExtract | Where-Object {$_.Name -notlike "*amd64*"}} if ($($OSMedia.Arch) -eq 'x86') {$ContentIsoExtract = $ContentIsoExtract | Where-Object {$_.FullName -notlike "*\x64\*"}} if ($($OSMedia.Arch) -eq 'x86') {$ContentIsoExtract = $ContentIsoExtract | Where-Object {$_.FullName -notlike "*\amd64\*"}} Return $ContentIsoExtract } function Get-TaskContentLanguageCopySources { #=================================================================================================== # Content Scripts #=================================================================================================== [CmdletBinding()] Param () $LanguageCopySources = Get-OSMedia -Revision OK $LanguageCopySources = $LanguageCopySources | Where-Object {$_.Arch -eq $OSMedia.Arch} $LanguageCopySources = $LanguageCopySources | Where-Object {$_.Build -eq $OSMedia.Build} $LanguageCopySources = $LanguageCopySources | Where-Object {$_.OperatingSystem -eq $OSMedia.OperatingSystem} $LanguageCopySources = $LanguageCopySources | Where-Object {$_.OSMFamily -ne $OSMedia.OSMFamily} if ($ExistingTask.LanguageCopySources) { foreach ($Item in $ExistingTask.LanguageCopySources) { $LanguageCopySources = $LanguageCopySources | Where-Object {$_.OSMFamily -ne $Item} } } $LanguageCopySources = $LanguageCopySources | Out-GridView -Title "SourcesLanguageCopy: Select OSMedia to copy the Language Sources and press OK (Esc or Cancel to Skip)" -PassThru foreach ($Item in $LanguageCopySources) {Write-Host "$($Item.OSMFamily)" -ForegroundColor White} Return $LanguageCopySources } function Get-TaskContentLanguageFeature { [CmdletBinding()] Param () $LanguageFodIsoExtractDir = @() $LanguageFodIsoExtractDir = $ContentIsoExtract | Where-Object {$_.Name -like "*LanguageFeatures*"} if ($OSMedia.InstallationType -eq 'Client') { if ($($OSMedia.Arch) -eq 'x86') {$LanguageFodIsoExtractDir = $LanguageFodIsoExtractDir | Where-Object {$_.FullName -like "*x86*"}} if ($($OSMedia.Arch) -eq 'x64') {$LanguageFodIsoExtractDir = $LanguageFodIsoExtractDir | Where-Object {$_.FullName -like "*x64*" -or $_.FullName -like "*amd64*"}} } $LanguageFodUpdatesDir = @() if (Test-Path "$OSDBuilderContent\Updates\LanguageFeature") { $LanguageFodUpdatesDir = Get-ChildItem -Path "$OSDBuilderContent\Updates\LanguageFeature" *.cab -Recurse | Select-Object -Property Name, FullName foreach ($Package in $LanguageFodUpdatesDir) {$Package.FullName = $($Package.FullName).replace("$OSDBuilderContent\",'')} if ($($OSMedia.Arch) -eq 'x86') {$LanguageFodUpdatesDir = $LanguageFodUpdatesDir | Where-Object {$_.FullName -like "*x86*"}} if ($($OSMedia.Arch) -eq 'x64') {$LanguageFodUpdatesDir = $LanguageFodUpdatesDir | Where-Object {$_.FullName -like "*x64*" -or $_.FullName -like "*amd64*"}} if ($($OSMedia.ReleaseId)) { if ($($OSMedia.ReleaseId) -eq 1909) { $LanguageFodUpdatesDir = $LanguageFodUpdatesDir | Where-Object {$_.FullName -match '1903' -or $_.FullName -match '1909'} } else { $LanguageFodUpdatesDir = $LanguageFodUpdatesDir | Where-Object {$_.FullName -like "*$($OSMedia.ReleaseId)*"} } } } [array]$LanguageFeature = [array]$LanguageFodIsoExtractDir + [array]$LanguageFodUpdatesDir if ($null -eq $LanguageFeature) {Write-Warning "Install.wim Language Features On Demand: Not Found"} else { if ($ExistingTask.LanguageFeature) { foreach ($Item in $ExistingTask.LanguageFeature) { $LanguageFeature = $LanguageFeature | Where-Object {$_.FullName -ne $Item} } } $LanguageFeature = $LanguageFeature | Sort-Object -Property FullName | Out-GridView -Title "Install.wim Language Features On Demand: Select Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $LanguageFeature) {Write-Warning "Install.wim Language Features On Demand: Skipping"} } foreach ($Item in $LanguageFeature) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $LanguageFeature } function Get-TaskContentLanguageInterfacePack { [CmdletBinding()] Param () $LanguageLipIsoExtractDir = @() $LanguageLipIsoExtractDir = $ContentIsoExtract | Where-Object {$_.Name -like "*Language-Interface-Pack*"} $LanguageLipIsoExtractDir = $LanguageLipIsoExtractDir | Where-Object {$_.Name -like "*$($OSMedia.Arch)*"} $LanguageLipUpdatesDir = @() if (Test-Path "$OSDBuilderContent\Updates\LanguageInterfacePack") { $LanguageLipUpdatesDir = Get-ChildItem -Path "$OSDBuilderContent\Updates\LanguageInterfacePack" *.cab -Recurse | Select-Object -Property Name, FullName foreach ($Package in $LanguageLipUpdatesDir) {$Package.FullName = $($Package.FullName).replace("$OSDBuilderContent\",'')} $LanguageLipUpdatesDir = $LanguageLipUpdatesDir | Where-Object {$_.FullName -like "*$($OSMedia.Arch)*"} if ($($OSMedia.ReleaseId)) { if ($($OSMedia.ReleaseId) -eq 1909) { $LanguageLipUpdatesDir = $LanguageLipUpdatesDir | Where-Object {$_.FullName -match '1903' -or $_.FullName -match '1909'} } else { $LanguageLipUpdatesDir = $LanguageLipUpdatesDir | Where-Object {$_.FullName -like "*$($OSMedia.ReleaseId)*"} } } } [array]$LanguageInterfacePack = [array]$LanguageLipIsoExtractDir + [array]$LanguageLipUpdatesDir if ($null -eq $LanguageInterfacePack) {Write-Warning "Install.wim Language Interface Packs: Not Found"} else { if ($ExistingTask.LanguageInterfacePack) { foreach ($Item in $ExistingTask.LanguageInterfacePack) { $LanguageInterfacePack = $LanguageInterfacePack | Where-Object {$_.FullName -ne $Item} } } $LanguageInterfacePack = $LanguageInterfacePack | Sort-Object -Property FullName | Out-GridView -Title "Install.wim Language Interface Packs: Select Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru if($null -eq $LanguageInterfacePack) {Write-Warning "Install.wim Language Interface Packs: Skipping"} } foreach ($Item in $LanguageInterfacePack) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $LanguageInterfacePack } function Get-TaskContentLanguagePack { [CmdletBinding()] Param () $LanguageLpIsoExtractDir = @() $LanguageLpIsoExtractDir = $ContentIsoExtract | Where-Object {$_.FullName -notlike "*FOD*"} $LanguageLpIsoExtractDir = $LanguageLpIsoExtractDir | Where-Object {$_.FullName -notlike "*LanguageFeatures*"} $LanguageLpIsoExtractDir = $LanguageLpIsoExtractDir | Where-Object {$_.FullName -like "*\langpacks\*"} $LanguageLpIsoExtractDir = $LanguageLpIsoExtractDir | Where-Object {$_.Name -notlike "*Language-Interface-Pack*"} $LanguageLpUpdatesDir = @() if (Test-Path "$OSDBuilderContent\Updates\LanguagePack") { $LanguageLpUpdatesDir = Get-ChildItem -Path "$OSDBuilderContent\Updates\LanguagePack" *.cab -Recurse | Select-Object -Property Name, FullName $LanguageLpUpdatesDir = $LanguageLpUpdatesDir | Where-Object {$_.FullName -like "*$($OSMedia.Arch)*"} } $LanguageLpLegacyDir = @() if (Test-Path "$OSDBuilderContent\LanguagePacks") { $LanguageLpLegacyDir = Get-ChildItem -Path "$OSDBuilderContent\LanguagePacks" *.cab -Recurse | Select-Object -Property Name, FullName $LanguageLpLegacyDir = $LanguageLpLegacyDir | Where-Object {$_.FullName -like "*$($OSMedia.Arch)*"} } [array]$LanguagePack = [array]$LanguageLpIsoExtractDir + [array]$LanguageLpUpdatesDir + [array]$LanguageLpLegacyDir if ($OSMedia.InstallationType -eq 'Client') {$LanguagePack = $LanguagePack | Where-Object {$_.FullName -notlike "*Windows Server*"}} if ($OSMedia.InstallationType -like "*Server*") {$LanguagePack = $LanguagePack | Where-Object {$_.FullName -like "*Windows Server*"}} if ($($OSMedia.ReleaseId)) { if ($($OSMedia.ReleaseId) -eq 1909) { $LanguagePack = $LanguagePack | Where-Object {$_.FullName -match '1903' -or $_.FullName -match '1909'} } else { $LanguagePack = $LanguagePack | Where-Object {$_.FullName -like "*$($OSMedia.ReleaseId)*"} } } foreach ($Package in $LanguagePack) {$Package.FullName = $($Package.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $LanguagePack) {Write-Warning "Install.wim Language Packs: Not Found"} else { if ($ExistingTask.LanguagePack) { foreach ($Item in $ExistingTask.LanguagePack) { $LanguagePack = $LanguagePack | Where-Object {$_.FullName -ne $Item} } } $LanguagePack = $LanguagePack | Sort-Object -Property FullName | Out-GridView -Title "Install.wim Language Packs: Select Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru if ($null -eq $LanguagePack) {Write-Warning "Install.wim Language Packs: Skipping"} } foreach ($Item in $LanguagePack) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $LanguagePack } function Get-TaskContentLocalExperiencePacks { [CmdletBinding()] Param () $LocalExperiencePacks = $ContentIsoExtract | Where-Object {$_.FullName -like "*\LocalExperiencePack\*" -and $_.Name -like "*.appx"} if ($OSMedia.InstallationType -eq 'Client') {$LocalExperiencePacks = $LocalExperiencePacks | Where-Object {$_.FullName -notlike "*Server*"}} if ($OSMedia.InstallationType -eq 'Server') {$LocalExperiencePacks = $LocalExperiencePacks | Where-Object {$_.FullName -like "*Server*"}} if ($OSMedia.InstallationType -eq 'Server') {$LocalExperiencePacks = $LocalExperiencePacks | Where-Object {$_.FullName -notlike "*Windows 10*"}} foreach ($Pack in $LocalExperiencePacks) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $LocalExperiencePacks) {Write-Warning "Install.wim Local Experience Packs: Not Found"} else { if ($ExistingTask.LocalExperiencePacks) { foreach ($Item in $ExistingTask.LocalExperiencePacks) { $LocalExperiencePacks = $LocalExperiencePacks | Where-Object {$_.FullName -ne $Item} } } $LocalExperiencePacks = $LocalExperiencePacks | Sort-Object -Property FullName | Out-GridView -Title "Install.wim Local Experience Packs: Select Capabilities to apply and press OK (Esc or Cancel to Skip)" -PassThru if ($null -eq $LocalExperiencePacks) {Write-Warning "Install.wim Local Experience Packs: Skipping"} } foreach ($Item in $LocalExperiencePacks) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $LocalExperiencePacks } function Get-TaskContentScripts { #=================================================================================================== # Content Scripts #=================================================================================================== [CmdletBinding()] Param () $Scripts = Get-ChildItem -Path "$OSDBuilderContent\Scripts" *.ps1 -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName, Length, CreationTime | Sort-Object -Property FullName foreach ($Item in $Scripts) {$Item.FullName = $($Item.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $Scripts) {Write-Warning "Scripts: To select PowerShell Scripts add Content to $OSDBuilderContent\Scripts"} else { if ($ExistingTask.Scripts) { foreach ($Item in $ExistingTask.Scripts) { $Scripts = $Scripts | Where-Object {$_.FullName -ne $Item} } } $Scripts = $Scripts | Out-GridView -Title "Scripts: Select PowerShell Scripts to execute and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $Scripts) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $Scripts } function Get-TaskContentStartLayoutXML { #=================================================================================================== # Content StartLayout #=================================================================================================== [CmdletBinding()] Param () $StartLayoutXML = Get-ChildItem -Path "$OSDBuilderContent\StartLayout" *.xml -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName, Length, CreationTime | Sort-Object -Property FullName foreach ($Item in $StartLayoutXML) {$Item.FullName = $($Item.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $StartLayoutXML) {Write-Warning "StartLayoutXML: To select a Start Layout, add Content to $OSDBuilderContent\StartLayout"} else { if ($ExistingTask.StartLayoutXML) { foreach ($Item in $ExistingTask.StartLayoutXML) { $StartLayoutXML = $StartLayoutXML | Where-Object {$_.FullName -ne $Item} } } $StartLayoutXML = $StartLayoutXML | Out-GridView -Title "StartLayoutXML: Select a Start Layout XML to apply and press OK (Esc or Cancel to Skip)" -OutputMode Single } foreach ($Item in $StartLayoutXML) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $StartLayoutXML } function Get-TaskContentUnattendXML { #=================================================================================================== # Content Unattend #=================================================================================================== [CmdletBinding()] Param () $UnattendXML = Get-ChildItem -Path "$OSDBuilderContent\Unattend" *.xml -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName, Length, CreationTime | Sort-Object -Property FullName foreach ($Item in $UnattendXML) {$Item.FullName = $($Item.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $UnattendXML) {Write-Warning "UnattendXML: To select an Unattend XML, add Content to $OSDBuilderContent\Unattend"} else { if ($ExistingTask.UnattendXML) { foreach ($Item in $ExistingTask.UnattendXML) { $UnattendXML = $UnattendXML | Where-Object {$_.FullName -ne $Item} } } $UnattendXML = $UnattendXML | Out-GridView -Title "UnattendXML: Select a Windows Unattend XML File to apply and press OK (Esc or Cancel to Skip)" -OutputMode Single } foreach ($Item in $UnattendXML) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $UnattendXML } function Get-TaskDisableWindowsOptionalFeature { #=================================================================================================== # DisableWindowsOptionalFeature #=================================================================================================== [CmdletBinding()] Param () if (Test-Path "$($OSMedia.FullName)\info\xml\Get-WindowsOptionalFeature.xml") { $DisableWindowsOptionalFeature = Import-CliXml "$($OSMedia.FullName)\info\xml\Get-WindowsOptionalFeature.xml" } $DisableWindowsOptionalFeature = $DisableWindowsOptionalFeature | Select-Object -Property FeatureName, State | Sort-Object -Property FeatureName | Where-Object {$_.State -eq 2 -or $_.State -eq 3} $DisableWindowsOptionalFeature = $DisableWindowsOptionalFeature | Select-Object -Property FeatureName if ($ExistingTask.DisableWindowsOptionalFeature) { foreach ($Item in $ExistingTask.DisableWindowsOptionalFeature) { $DisableWindowsOptionalFeature = $DisableWindowsOptionalFeature | Where-Object {$_.FeatureName -ne $Item} } } $DisableWindowsOptionalFeature = $DisableWindowsOptionalFeature | Out-GridView -PassThru -Title "Disable-WindowsOptionalFeature: Select Windows Optional Features to Disable and press OK (Esc or Cancel to Skip)" foreach ($Item in $DisableWindowsOptionalFeature) {Write-Host "$($Item.FeatureName)" -ForegroundColor White} Return $DisableWindowsOptionalFeature } function Get-TaskEnableWindowsOptionalFeature { #=================================================================================================== # EnableWindowsOptionalFeature #=================================================================================================== [CmdletBinding()] Param () if (Test-Path "$($OSMedia.FullName)\info\xml\Get-WindowsOptionalFeature.xml") { $EnableWindowsOptionalFeature = Import-CliXml "$($OSMedia.FullName)\info\xml\Get-WindowsOptionalFeature.xml" } $EnableWindowsOptionalFeature = $EnableWindowsOptionalFeature | Select-Object -Property FeatureName, State | Sort-Object -Property FeatureName | Where-Object {$_.State -eq 0} $EnableWindowsOptionalFeature = $EnableWindowsOptionalFeature | Select-Object -Property FeatureName if ($ExistingTask.EnableWindowsOptionalFeature) { foreach ($Item in $ExistingTask.EnableWindowsOptionalFeature) { $EnableWindowsOptionalFeature = $EnableWindowsOptionalFeature | Where-Object {$_.FeatureName -ne $Item} } } $EnableWindowsOptionalFeature = $EnableWindowsOptionalFeature | Out-GridView -PassThru -Title "Enable-WindowsOptionalFeature: Select Windows Optional Features to ENABLE and press OK (Esc or Cancel to Skip)" foreach ($Item in $EnableWindowsOptionalFeature) {Write-Host "$($Item.FeatureName)" -ForegroundColor White} Return $EnableWindowsOptionalFeature } function Get-TaskRemoveAppxProvisionedPackage { #=================================================================================================== # RemoveAppx #=================================================================================================== [CmdletBinding()] Param () if ($($OSMedia.InstallationType) -eq 'Client') { if (Test-Path "$($OSMedia.FullName)\info\xml\Get-AppxProvisionedPackage.xml") { $RemoveAppxProvisionedPackage = Import-CliXml "$($OSMedia.FullName)\info\xml\Get-AppxProvisionedPackage.xml" $RemoveAppxProvisionedPackage = $RemoveAppxProvisionedPackage | Select-Object -Property DisplayName, PackageName if ($ExistingTask.RemoveAppxProvisionedPackage) { foreach ($Item in $ExistingTask.RemoveAppxProvisionedPackage) { $RemoveAppxProvisionedPackage = $RemoveAppxProvisionedPackage | Where-Object {$_.PackageName -ne $Item} } } $RemoveAppxProvisionedPackage = $RemoveAppxProvisionedPackage | Out-GridView -Title "Remove-AppxProvisionedPackage: Select Packages to REMOVE and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $RemoveAppxProvisionedPackage) {Write-Host "$($Item.PackageName)" -ForegroundColor White} Return $RemoveAppxProvisionedPackage } else {Write-Warning "Remove-AppxProvisionedPackage: Unsupported"} } function Get-TaskRemoveWindowsCapability { #=================================================================================================== # RemoveCapability #=================================================================================================== [CmdletBinding()] Param () if (Test-Path "$($OSMedia.FullName)\info\xml\Get-WindowsCapability.xml") { $RemoveWindowsCapability = Import-CliXml "$($OSMedia.FullName)\info\xml\Get-WindowsCapability.xml" $RemoveWindowsCapability = $RemoveWindowsCapability | Where-Object {$_.State -eq 4} $RemoveWindowsCapability = $RemoveWindowsCapability | Select-Object -Property Name, State if ($ExistingTask.RemoveWindowsCapability) { foreach ($Item in $ExistingTask.RemoveWindowsCapability) { $RemoveWindowsCapability = $RemoveWindowsCapability | Where-Object {$_.Name -ne $Item} } } $RemoveWindowsCapability = $RemoveWindowsCapability | Out-GridView -Title "Remove-WindowsCapability: Select Windows InBox Capability to REMOVE and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $RemoveWindowsCapability) {Write-Host "$($Item.Name)" -ForegroundColor White} Return $RemoveWindowsCapability } function Get-TaskRemoveWindowsPackage { #=================================================================================================== # RemovePackage #=================================================================================================== [CmdletBinding()] Param () if (Test-Path "$($OSMedia.FullName)\info\xml\Get-WindowsPackage.xml") { $RemoveWindowsPackage = Import-CliXml "$($OSMedia.FullName)\info\xml\Get-WindowsPackage.xml" $RemoveWindowsPackage = $RemoveWindowsPackage | Select-Object -Property PackageName if ($ExistingTask.RemoveWindowsPackage) { foreach ($Item in $ExistingTask.RemoveWindowsPackage) { $RemoveWindowsPackage = $RemoveWindowsPackage | Where-Object {$_.PackageName -ne $Item} } } $RemoveWindowsPackage = $RemoveWindowsPackage | Out-GridView -Title "Remove-WindowsPackage: Select Packages to REMOVE and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $RemoveWindowsPackage) {Write-Host "$($Item.PackageName)" -ForegroundColor White} Return $RemoveWindowsPackage } function Get-TaskWinPEADK { #=================================================================================================== # WinPE ADK #=================================================================================================== [CmdletBinding()] Param () $WinPEADK = Get-ChildItem -Path ("$OSDBuilderContent\WinPE\ADK\*","$OSDBuilderContent\ADK\*\Windows Preinstallation Environment\*\WinPE_OCs") *.cab -Recurse -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName foreach ($Pack in $WinPEADK) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($($OSMedia.ReleaseId) -eq 1909) { $WinPEADK = $WinPEADK | Where-Object {$_.FullName -match '1903' -or $_.FullName -match '1909'} } else { $WinPEADK = $WinPEADK | Where-Object {$_.FullName -like "*$($OSMedia.ReleaseId)*"} } if ($OSMedia.Arch -eq 'x86') {$WinPEADK = $WinPEADK | Where-Object {$_.FullName -like "*x86*"} } else {$WinPEADK = $WinPEADK | Where-Object {($_.FullName -like "*x64*") -or ($_.FullName -like "*amd64*")}} $WinPEADKIE = @() $WinPEADKIE = $ContentIsoExtractWinPE | Select-Object -Property Name, FullName [array]$WinPEADK = [array]$WinPEADK + [array]$WinPEADKIE if ($null -eq $WinPEADK) {Write-Warning "WinPE.wim ADK Packages: Add Content to $OSDBuilderContent\ADK"} else { if ($ExistingTask.WinPEADK) { foreach ($Item in $ExistingTask.WinPEADK) { $WinPEADK = $WinPEADK | Where-Object {$_.FullName -ne $Item} } } $WinPEADK = $WinPEADK | Out-GridView -Title "WinPE.wim ADK Packages: Select ADK Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEADK) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEADK } function Get-TaskWinPEADKPE { #=================================================================================================== # WinPE ADK #=================================================================================================== [CmdletBinding()] Param () $WinPEADKPE = Get-ChildItem -Path ("$OSDBuilderContent\WinPE\ADK\*","$OSDBuilderContent\ADK\*\Windows Preinstallation Environment\*\WinPE_OCs") *.cab -Recurse -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName foreach ($Pack in $WinPEADKPE) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($($OSMedia.ReleaseId) -eq 1909) { $WinPEADKPE = $WinPEADKPE | Where-Object {$_.FullName -match '1903' -or $_.FullName -match '1909'} } else { $WinPEADKPE = $WinPEADKPE | Where-Object {$_.FullName -like "*$($OSMedia.ReleaseId)*"} } if ($OSMedia.Arch -eq 'x86') {$WinPEADKPE = $WinPEADKPE | Where-Object {$_.FullName -like "*x86*"} } else {$WinPEADKPE = $WinPEADKPE | Where-Object {($_.FullName -like "*x64*") -or ($_.FullName -like "*amd64*")}} $WinPEADKPEIE = @() $WinPEADKPEIE = $ContentIsoExtractWinPE | Select-Object -Property Name, FullName [array]$WinPEADKPE = [array]$WinPEADKPE + [array]$WinPEADKPEIE if ($null -eq $WinPEADKPE) {Write-Warning "WinPE.wim ADK Packages: Add Content to $OSDBuilderContent\ADK"} else { if ($ExistingTask.WinPEADKPE) { foreach ($Item in $ExistingTask.WinPEADKPE) { $WinPEADKPE = $WinPEADKPE | Where-Object {$_.FullName -ne $Item} } } $WinPEADKPE = $WinPEADKPE | Out-GridView -Title "WinPE.wim ADK Packages: Select ADK Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEADKPE) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEADKPE } function Get-TaskWinPEADKRE { #=================================================================================================== # WinRE ADK #=================================================================================================== [CmdletBinding()] Param () $WinPEADKRE = Get-ChildItem -Path ("$OSDBuilderContent\WinPE\ADK\*","$OSDBuilderContent\ADK\*\Windows Preinstallation Environment\*\WinPE_OCs") *.cab -Recurse -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName foreach ($Pack in $WinPEADKRE) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($($OSMedia.ReleaseId) -eq 1909) { $WinPEADKRE = $WinPEADKRE | Where-Object {$_.FullName -match '1903' -or $_.FullName -match '1909'} } else { $WinPEADKRE = $WinPEADKRE | Where-Object {$_.FullName -like "*$($OSMedia.ReleaseId)*"} } if ($OSMedia.Arch -eq 'x86') {$WinPEADKRE = $WinPEADKRE | Where-Object {$_.FullName -like "*x86*"} } else {$WinPEADKRE = $WinPEADKRE | Where-Object {($_.FullName -like "*x64*") -or ($_.FullName -like "*amd64*")}} $WinPEADKREIE = @() $WinPEADKREIE = $ContentIsoExtractWinPE | Select-Object -Property Name, FullName [array]$WinPEADKRE = [array]$WinPEADKRE + [array]$WinPEADKREIE if ($null -eq $WinPEADKRE) {Write-Warning "WinRE.wim ADK Packages: Add Content to $OSDBuilderContent\ADK"} else { if ($ExistingTask.WinPEADKRE) { foreach ($Item in $ExistingTask.WinPEADKRE) { $WinPEADKRE = $WinPEADKRE | Where-Object {$_.FullName -ne $Item} } } 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" $WinPEADKRE = $WinPEADKRE | Out-GridView -Title "WinRE.wim ADK Packages: Select ADK Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEADKRE) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEADKRE } function Get-TaskWinPEADKSE { #=================================================================================================== # WinRE ADK #=================================================================================================== [CmdletBinding()] Param () $WinPEADKSE = Get-ChildItem -Path ("$OSDBuilderContent\WinPE\ADK\*","$OSDBuilderContent\ADK\*\Windows Preinstallation Environment\*\WinPE_OCs") *.cab -Recurse -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName foreach ($Pack in $WinPEADKSE) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($($OSMedia.ReleaseId) -eq 1909) { $WinPEADKSE = $WinPEADKSE | Where-Object {$_.FullName -match '1903' -or $_.FullName -match '1909'} } else { $WinPEADKSE = $WinPEADKSE | Where-Object {$_.FullName -like "*$($OSMedia.ReleaseId)*"} } if ($OSMedia.Arch -eq 'x86') {$WinPEADKSE = $WinPEADKSE | Where-Object {$_.FullName -like "*x86*"} } else {$WinPEADKSE = $WinPEADKSE | Where-Object {($_.FullName -like "*x64*") -or ($_.FullName -like "*amd64*")}} $WinPEADKSEIE = @() $WinPEADKSEIE = $ContentIsoExtractWinPE | Select-Object -Property Name, FullName [array]$WinPEADKSE = [array]$WinPEADKSE + [array]$WinPEADKSEIE if ($null -eq $WinPEADKSE) {Write-Warning "WinSE.wim ADK Packages: Add Content to $OSDBuilderContent\ADK"} else { if ($ExistingTask.WinPEADKSE) { foreach ($Item in $ExistingTask.WinPEADKSE) { $WinPEADKSE = $WinPEADKSE | Where-Object {$_.FullName -ne $Item} } } $WinPEADKSE = $WinPEADKSE | Out-GridView -Title "WinSE.wim ADK Packages: Select ADK Packages to apply and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEADKSE) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEADKSE } function Get-TaskWinPEDaRT { #=================================================================================================== # WinPE DaRT #=================================================================================================== [CmdletBinding()] Param () $WinPEDaRT = Get-ChildItem -Path ("$OSDBuilderContent\DaRT","$OSDBuilderContent\WinPE\DaRT") *.cab -Recurse -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName $WinPEDaRT = $WinPEDaRT | Where-Object {$_.FullName -like "*$($OSMedia.Arch)*"} foreach ($Pack in $WinPEDaRT) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEDaRT) {Write-Warning "WinPEDaRT: Add Content to $OSDBuilderContent\DaRT"} else { if ($ExistingTask.WinPEDaRT) { foreach ($Item in $ExistingTask.WinPEDaRT) { $WinPEDaRT = $WinPEDaRT | Where-Object {$_.FullName -ne $Item} } } $WinPEDaRT = $WinPEDaRT | Out-GridView -Title "WinPEDaRT: Select a WinPE DaRT Package to apply and press OK (Esc or Cancel to Skip)" -OutputMode Single } foreach ($Item in $WinPEDaRT) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEDaRT } function Get-TaskWinPEDrivers { #=================================================================================================== # WinPE Add-WindowsDriver #=================================================================================================== [CmdletBinding()] Param () $WinPEDrivers = Get-ChildItem -Path ("$OSDBuilderContent\Drivers","$OSDBuilderContent\WinPE\Drivers") -Directory -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName foreach ($Pack in $WinPEDrivers) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEDrivers) {Write-Warning "WinPEDrivers: To select WinPE Drivers, add Content to $OSDBuilderContent\Drivers"} else { if ($ExistingTask.WinPEDrivers) { foreach ($Item in $ExistingTask.WinPEDrivers) { $WinPEDrivers = $WinPEDrivers | Where-Object {$_.FullName -ne $Item} } } $WinPEDrivers = $WinPEDrivers | Out-GridView -Title "WinPEDrivers: Select Driver Paths to apply and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEDrivers) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEDrivers } function Get-TaskWinPEExtraFiles { #=================================================================================================== # WinPEExtraFiles #=================================================================================================== [CmdletBinding()] Param () $WinPEExtraFiles = Get-ChildItem -Path ("$OSDBuilderContent\ExtraFiles","$OSDBuilderContent\WinPE\ExtraFiles") -Directory -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName $WinPEExtraFiles = $WinPEExtraFiles | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} foreach ($Pack in $WinPEExtraFiles) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEExtraFiles) {Write-Warning "WinPEExtraFiles: To select WinPE Extra Files, add Content to $OSDBuilderContent\ExtraFiles"} else { if ($ExistingTask.WinPEExtraFiles) { foreach ($Item in $ExistingTask.WinPEExtraFiles) { $WinPEExtraFiles = $WinPEExtraFiles | Where-Object {$_.FullName -ne $Item} } } $WinPEExtraFiles = $WinPEExtraFiles | Out-GridView -Title "WinPEExtraFiles: Select directories to inject and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEExtraFiles) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEExtraFiles } function Get-TaskWinPEExtraFilesPE { #=================================================================================================== # WinPEExtraFilesPE #=================================================================================================== [CmdletBinding()] Param () $WinPEExtraFilesPE = Get-ChildItem -Path ("$OSDBuilderContent\ExtraFiles","$OSDBuilderContent\WinPE\ExtraFiles") -Directory -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName $WinPEExtraFilesPE = $WinPEExtraFilesPE | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} foreach ($Pack in $WinPEExtraFilesPE) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEExtraFilesPE) {Write-Warning "WinPEExtraFilesPE: To select WinPE Extra Files, add Content to $OSDBuilderContent\ExtraFiles"} else { if ($ExistingTask.WinPEExtraFilesPE) { foreach ($Item in $ExistingTask.WinPEExtraFilesPE) { $WinPEExtraFilesPE = $WinPEExtraFilesPE | Where-Object {$_.FullName -ne $Item} } } $WinPEExtraFilesPE = $WinPEExtraFilesPE | Out-GridView -Title "WinPEExtraFilesPE: Select directories to inject and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEExtraFilesPE) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEExtraFilesPE } function Get-TaskWinPEExtraFilesRE { #=================================================================================================== # WinPEExtraFilesRE #=================================================================================================== [CmdletBinding()] Param () $WinPEExtraFilesRE = Get-ChildItem -Path ("$OSDBuilderContent\ExtraFiles","$OSDBuilderContent\WinPE\ExtraFiles") -Directory -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName $WinPEExtraFilesRE = $WinPEExtraFilesRE | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} foreach ($Pack in $WinPEExtraFilesRE) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEExtraFilesRE) {Write-Warning "WinPEExtraFilesRE: To select WinRE Extra Files, add Content to $OSDBuilderContent\ExtraFiles"} else { if ($ExistingTask.WinPEExtraFilesRE) { foreach ($Item in $ExistingTask.WinPEExtraFilesRE) { $WinPEExtraFilesRE = $WinPEExtraFilesRE | Where-Object {$_.FullName -ne $Item} } } $WinPEExtraFilesRE = $WinPEExtraFilesRE | Out-GridView -Title "WinPEExtraFilesRE: Select directories to inject and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEExtraFilesRE) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEExtraFilesRE } function Get-TaskWinPEExtraFilesSE { #=================================================================================================== # WinSE Add-ExtraFiles #=================================================================================================== [CmdletBinding()] Param () $WinPEExtraFilesSE = Get-ChildItem -Path ("$OSDBuilderContent\ExtraFiles","$OSDBuilderContent\WinPE\ExtraFiles") -Directory -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName $WinPEExtraFilesSE = $WinPEExtraFilesSE | Where-Object {(Get-ChildItem $_.FullName | Measure-Object).Count -gt 0} foreach ($Pack in $WinPEExtraFilesSE) {$Pack.FullName = $($Pack.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEExtraFilesSE) {Write-Warning "WinPEExtraFilesSE: To select WinSE Extra Files, add Content to $OSDBuilderContent\ExtraFiles"} else { if ($ExistingTask.WinPEExtraFilesSE) { foreach ($Item in $ExistingTask.WinPEExtraFilesSE) { $WinPEExtraFilesSE = $WinPEExtraFilesSE | Where-Object {$_.FullName -ne $Item} } } $WinPEExtraFilesSE = $WinPEExtraFilesSE | Out-GridView -Title "WinPEExtraFilesSE: Select directories to inject and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEExtraFilesSE) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEExtraFilesSE } function Get-TaskWinPEScripts { #=================================================================================================== # WinPE PowerShell Scripts #=================================================================================================== [CmdletBinding()] Param () $WinPEScripts = Get-ChildItem -Path ("$OSDBuilderContent\Scripts","$OSDBuilderContent\WinPE\Scripts") *.ps1 -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName, Length, CreationTime | Sort-Object -Property FullName foreach ($TaskScript in $WinPEScripts) {$TaskScript.FullName = $($TaskScript.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEScripts) {Write-Warning "WinPE PowerShell Scripts: To select PowerShell Scripts add Content to $OSDBuilderContent\Scripts"} else { if ($ExistingTask.WinPEScripts) { foreach ($Item in $ExistingTask.WinPEScripts) { $WinPEScripts = $WinPEScripts | Where-Object {$_.FullName -ne $Item} } } $WinPEScripts = $WinPEScripts | Out-GridView -Title "WinPE PowerShell Scripts: Select PowerShell Scripts to execute and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEScripts) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEScripts } function Get-TaskWinPEScriptsPE { #=================================================================================================== # WinPE PowerShell Scripts #=================================================================================================== [CmdletBinding()] Param () $WinPEScriptsPE = Get-ChildItem -Path ("$OSDBuilderContent\Scripts","$OSDBuilderContent\WinPE\Scripts") *.ps1 -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName, Length, CreationTime | Sort-Object -Property FullName foreach ($TaskScript in $WinPEScriptsPE) {$TaskScript.FullName = $($TaskScript.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEScriptsPE) {Write-Warning "WinPE PowerShell Scripts: To select PowerShell Scripts add Content to $OSDBuilderContent\Scripts"} else { if ($ExistingTask.WinPEScriptsPE) { foreach ($Item in $ExistingTask.WinPEScriptsPE) { $WinPEScriptsPE = $WinPEScriptsPE | Where-Object {$_.FullName -ne $Item} } } $WinPEScriptsPE = $WinPEScriptsPE | Out-GridView -Title "WinPE PowerShell Scripts: Select PowerShell Scripts to execute and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEScriptsPE) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEScriptsPE } function Get-TaskWinPEScriptsRE { #=================================================================================================== # WinRE PowerShell Scripts #=================================================================================================== [CmdletBinding()] Param () $WinPEScriptsRE = Get-ChildItem -Path ("$OSDBuilderContent\Scripts","$OSDBuilderContent\WinPE\Scripts") *.ps1 -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName, Length, CreationTime | Sort-Object -Property FullName foreach ($TaskScript in $WinPEScriptsRE) {$TaskScript.FullName = $($TaskScript.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEScriptsRE) {Write-Warning "WinRE PowerShell Scripts: To select PowerShell Scripts add Content to $OSDBuilderContent\Scripts"} else { if ($ExistingTask.WinPEScriptsRE) { foreach ($Item in $ExistingTask.WinPEScriptsRE) { $WinPEScriptsRE = $WinPEScriptsRE | Where-Object {$_.FullName -ne $Item} } } $WinPEScriptsRE = $WinPEScriptsRE | Out-GridView -Title "WinRE PowerShell Scripts: Select PowerShell Scripts to execute and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEScriptsRE) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEScriptsRE } function Get-TaskWinPEScriptsSE { #=================================================================================================== # WinSE PowerShell Scripts #=================================================================================================== [CmdletBinding()] Param () $WinPEScriptsSE = Get-ChildItem -Path ("$OSDBuilderContent\Scripts","$OSDBuilderContent\WinPE\Scripts") *.ps1 -ErrorAction SilentlyContinue | Select-Object -Property Name, FullName, Length, CreationTime | Sort-Object -Property FullName foreach ($TaskScript in $WinPEScriptsSE) {$TaskScript.FullName = $($TaskScript.FullName).replace("$OSDBuilderContent\",'')} if ($null -eq $WinPEScriptsSE) {Write-Warning "WinSE PowerShell Scripts: To select PowerShell Scripts add Content to $OSDBuilderContent\Scripts"} else { if ($ExistingTask.WinPEScriptsSE) { foreach ($Item in $ExistingTask.WinPEScriptsSE) { $WinPEScriptsSE = $WinPEScriptsSE | Where-Object {$_.FullName -ne $Item} } } $WinPEScriptsSE = $WinPEScriptsSE | Out-GridView -Title "WinSE PowerShell Scripts: Select PowerShell Scripts to execute and press OK (Esc or Cancel to Skip)" -PassThru } foreach ($Item in $WinPEScriptsSE) {Write-Host "$($Item.FullName)" -ForegroundColor White} Return $WinPEScriptsSE } |