Public/Import-OSMedia.ps1
<# .SYNOPSIS Imports an Operating System into OSBuilder .DESCRIPTION Imports a supported Operating System into the OSBuilder OSMedia directory .LINK https://www.osdeploy.com/osbuilder/docs/functions/osmedia/import-osmedia .PARAMETER MediaISO Executes New-OSBMediaISO -FullName $FullName Creates an ISO after Import .PARAMETER INFO Executes Show-OSBMediaINFO -FullName $FullName Displays Media Information after Import .PARAMETER UpdateOSMedia Executes Update-OSMedia -Name $Name -DownloadUpdates -Execute Automatically updates the Imported Operating System .PARAMETER EditionId Operating System Edition to import .EXAMPLE Import-OSMedia -EditionId Enterprise .PARAMETER ImageIndex Operating System Index to Import .PARAMETER ImageName Operating System Image Name to Import .PARAMETER SkipGridView Used to bypass the ISE GridView Operating System Selection .EXAMPLE Import-OSMedia -EditionId Enterprise -SkipGridView .EXAMPLE Import-OSMedia -EditionId Enterprise -SkipGridView -UpdateOSMedia #> function Import-OSMedia { [CmdletBinding(DefaultParameterSetName='Basic')] PARAM ( [switch]$MediaINFO, [switch]$MediaISO, [switch]$UpdateOSMedia, [Parameter(ParameterSetName='Advanced')] [ValidateSet('Education','EducationN','Enterprise','EnterpriseN','EnterpriseS','EnterpriseSN','Professional','ProfessionalEducation','ProfessionalEducationN','ProfessionalN','ProfessionalWorkstation','ProfessionalWorkstationN','ServerRdsh','ServerDatacenter','ServerDatacenterACor','ServerRdsh','ServerStandard','ServerStandardACor')] [string]$EditionId, [Parameter(ParameterSetName='Advanced')] [int]$ImageIndex, [Parameter(ParameterSetName='Advanced')] [ValidateSet('Windows 10 Education','Windows 10 Education N','Windows 10 Enterprise','Windows 10 Enterprise 2016 LTSB','Windows 10 Enterprise for Virtual Desktops','Windows 10 Enterprise LTSC','Windows 10 Enterprise N','Windows 10 Enterprise N LTSC','Windows 10 Pro','Windows 10 Pro Education','Windows 10 Pro Education N','Windows 10 Pro for Workstations','Windows 10 Pro N','Windows 10 Pro N for Workstations','Windows Server 2016 Datacenter','Windows Server 2016 Datacenter (Desktop Experience)','Windows Server 2016 Standard','Windows Server 2016 Standard (Desktop Experience)','Windows Server 2019 Datacenter','Windows Server 2019 Datacenter (Desktop Experience)','Windows Server 2019 Standard','Windows Server 2019 Standard (Desktop Experience)','Windows Server Datacenter','Windows Server Standard')] [string]$ImageName, [Parameter(ParameterSetName='Advanced')] [switch]$SkipGridView ) BEGIN { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) BEGIN" -ForegroundColor Green #=================================================================================================== Write-Verbose '19.1.1 Validate Administrator Rights' #=================================================================================================== if (!([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Warning 'OSBuilder: This function needs to be run as Administrator' Return } #=================================================================================================== Write-Verbose '19.1.1 Initialize OSBuilder' #=================================================================================================== Get-OSBuilder -CreatePaths -HideDetails #=================================================================================================== Write-Verbose '19.1.1 Checking Drives' #=================================================================================================== $ImportWims = @() $ImportDrives = Get-PSDrive -PSProvider 'FileSystem' foreach ($ImportDrive in $ImportDrives) { if (Test-Path "$($ImportDrive.Root)Sources") {$ImportWims += Get-ChildItem "$($ImportDrive.Root)Sources" install.* | Select-Object -Property @{Name="OSRoot";Expression={(Get-Item $_.Directory).Parent.FullName}}, @{Name="OSWim";Expression={$_.FullName}}} if (Test-Path "$($ImportDrive.Root)x64\Sources") {$ImportWims += Get-ChildItem "$($ImportDrive.Root)x64\Sources" install.* | Select-Object -Property @{Name="OSRoot";Expression={(Get-Item $_.Directory).Parent.FullName}}, @{Name="OSWim";Expression={$_.FullName}}} if (Test-Path "$($ImportDrive.Root)x86\Sources") {$ImportWims += Get-ChildItem "$($ImportDrive.Root)x86\Sources" install.* | Select-Object -Property @{Name="OSRoot";Expression={(Get-Item $_.Directory).Parent.FullName}}, @{Name="OSWim";Expression={$_.FullName}}} } if ($null -eq $ImportWims) { Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Warning "Windows Image could not be found on any CD or DVD Drives . . . Exiting!" Break } #=================================================================================================== Write-Verbose '19.1.1 Media: Scan Windows Images' #=================================================================================================== $WindowsImages = $ImportWims | ForEach-Object { Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Media: Scan $($_.OSWim)" -ForegroundColor Green Get-WindowsImage -ImagePath "$($_.OSWim)"} | ForEach-Object { Get-WindowsImage -ImagePath "$($_.ImagePath)" -Index $($_.ImageIndex) | Select-Object -Property * Write-Host "Index $($_.ImageIndex): $($_.ImageName)" -ForegroundColor DarkGray } $WindowsImages = $WindowsImages | Select-Object -Property ImagePath, ImageIndex, ImageName, Architecture, EditionId, Languages, InstallationType, Version, MajorVersion, MinorVersion, Build, SPBuild, SPLevel, CreatedTime, ModifiedTime foreach ($Image in $WindowsImages) { if ($Image.Architecture -eq '0') {$Image.Architecture = 'x86'} if ($Image.Architecture -eq '6') {$Image.Architecture = 'ia64'} if ($Image.Architecture -eq '9') {$Image.Architecture = 'x64'} if ($Image.Architecture -eq '12') {$Image.Architecture = 'x64 ARM'} } #=================================================================================================== Write-Verbose '19.1.1 Filter OS Version 6.1.7601 and 10' #=================================================================================================== $WindowsImages = $WindowsImages | Where-Object {($_.Version -like "6.1.7601*") -or ($_.Version -like "6.3.9600*") -or $_.MajorVersion -eq '10'} #=================================================================================================== Write-Verbose '19.1.1 Filter Parameters' #=================================================================================================== if ($EditionId) {$WindowsImages = $WindowsImages | Where-Object {$_.EditionId -eq $EditionId}} if ($ImageName) {$WindowsImages = $WindowsImages | Where-Object {$_.ImageName -eq $ImageName}} if ($ImageIndex) {$WindowsImages = $WindowsImages | Where-Object {$_.ImageIndex -eq $ImageIndex}} #=================================================================================================== Write-Verbose '19.1.1 Select Operating Systems' #=================================================================================================== if (@($WindowsImages).Count -gt 0) { if (!($SkipGridView.IsPresent)) { $WindowsImages = $WindowsImages | Out-GridView -Title "Import-OSMedia: Select OSMedia to Import and press OK (Cancel to Exit)" -PassThru if($null -eq $WindowsImages) { Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Warning "Import-OSMedia: Compatible OSMedia was not selected . . . Exiting!" Return } } } else { Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Warning "OSMedia was not found . . . Exiting!" Return } } PROCESS { Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "$($MyInvocation.MyCommand.Name) PROCESS" -ForegroundColor Green #=================================================================================================== Write-Verbose '19.1.1 Import Windows Images' #=================================================================================================== foreach ($WindowsImage in $WindowsImages) { $OSImagePath = $($WindowsImage.ImagePath) $OSImageIndex = $($WindowsImage.ImageIndex) $OSSourcePath = (Get-Item $OSImagePath).Directory.Parent.FullName $WindowsImage = Get-WindowsImage -ImagePath "$OSImagePath" -Index $OSImageIndex | Select-Object -Property * $OSImageName = $($WindowsImage.ImageName) $OSImageName = $OSImageName -replace '\(', '' $OSImageName = $OSImageName -replace '\)', '' $OSImageDescription = $($WindowsImage.ImageDescription) $OSArchitecture = $($WindowsImage.Architecture) if ($OSArchitecture -eq '0') {$OSArchitecture = 'x86'} if ($OSArchitecture -eq '6') {$OSArchitecture = 'ia64'} if ($OSArchitecture -eq '9') {$OSArchitecture = 'x64'} if ($OSArchitecture -eq '12') {$OSArchitecture = 'x64 ARM'} $OSEditionID = $($WindowsImage.EditionId) $OSInstallationType = $($WindowsImage.InstallationType) $OSLanguages = $($WindowsImage.Languages) $OSMajorVersion = $($WindowsImage.MajorVersion) $OSBuild = $($WindowsImage.Build) $OSVersion = $($WindowsImage.Version) $OSSPBuild = $($WindowsImage.SPBuild) $OSSPLevel = $($WindowsImage.SPLevel) $OSImageBootable = $($WindowsImage.ImageBootable) $OSWIMBoot = $($WindowsImage.WIMBoot) $OSCreatedTime = $($WindowsImage.CreatedTime) $OSModifiedTime = $($WindowsImage.ModifiedTime) $OSMGuid = $(New-Guid) #=================================================================================================== Write-Verbose '19.1.1 Image: Export Install.esd' #=================================================================================================== if ($OSImagePath -like "*.esd") { $InstallWimType = "esd" $TempESD = "$env:Temp\$((Get-Date).ToString('HHmmss')).wim" Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Image: Export Install.esd Index $OSImageIndex to $TempESD" -ForegroundColor Green $CurrentLog = "$env:Temp\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Export-WindowsImage.log" Write-Verbose "$CurrentLog" Export-WindowsImage -SourceImagePath "$OSImagePath" -SourceIndex $OSImageIndex -DestinationImagePath "$TempESD" -CheckIntegrity -CompressionType max -LogPath "$CurrentLog" | Out-Null } else { $InstallWimType = "wim" } #=================================================================================================== Write-Verbose '19.1.1 Image: Mount Windows Image' #=================================================================================================== #Write-Host '========================================================================================' -ForegroundColor DarkGray $MountDirectory = Join-Path $OSBuilderContent\Mount "os$((Get-Date).ToString('HHmmss'))" if (!(Test-Path "$MountDirectory")) {New-Item "$MountDirectory" -ItemType Directory -Force | Out-Null} if ($InstallWimType -eq "esd") { Write-Host "Image: Mount $TempESD (Index 1) to $MountDirectory" -ForegroundColor Green Mount-WindowsImage -ImagePath "$TempESD" -Index '1' -Path "$MountDirectory" -ReadOnly | Out-Null } else { Write-Host "Image: Mount $OSImagePath (Index $OSImageIndex) to $MountDirectory" -ForegroundColor Green Mount-WindowsImage -ImagePath "$OSImagePath" -Index $OSImageIndex -Path "$MountDirectory" -ReadOnly | Out-Null } #=================================================================================================== Write-Verbose '19.1.1 Image: Get Registry and UBR' #=================================================================================================== #Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Image: Mount Registry for UBR Information" -ForegroundColor Green reg LOAD 'HKLM\OSMedia' "$MountDirectory\Windows\System32\Config\SOFTWARE" | Out-Null $RegCurrentVersion = Get-ItemProperty -Path 'HKLM:\OSMedia\Microsoft\Windows NT\CurrentVersion' reg UNLOAD 'HKLM\OSMedia' | Out-Null $OSVersionNumber = $null $RegCurrentVersionUBR = $null #=================================================================================================== Write-Verbose '19.1.1 Set OS Main Information' #=================================================================================================== if ($OSMajorVersion -eq '10') { $OSVersionNumber = $($RegCurrentVersion.ReleaseId) $RegCurrentVersionUBR = $($RegCurrentVersion.UBR) $UBR = "$OSBuild.$RegCurrentVersionUBR" if ($OSVersionNumber -gt 1809) {Write-Warning "OSBuilder does not currently support this version of Windows ... Check for an updated version"} $OSMediaName = "$OSImageName $OSArchitecture $OSVersionNumber $UBR $OSLanguages" } else { $UBR = "$OSBuild.$OSSPBuild" if ($OSBuild -eq '7601') { $OSMediaName = "$OSImageName $OSArchitecture SP1 $UBR $OSLanguages" } else { $OSMediaName = "$OSImageName $OSArchitecture $UBR $OSLanguages" } } if ($($OSLanguages.count) -eq 1) {$OSMediaName = $OSMediaName.replace(' en-US','')} #=================================================================================================== Write-Verbose '19.1.1 Set OSMediaPath' #=================================================================================================== $OSMediaPath = Join-Path $OSBuilderOSMedia $OSMediaName #=================================================================================================== Write-Verbose '19.1.1 Remove Existing OSMedia' #=================================================================================================== if (Test-Path $OSMediaPath) { Write-Warning "$OSMediaPath exists. Contents will be replaced!" Remove-Item -Path "$OSMediaPath" -Force -Recurse Write-Host "" } #=================================================================================================== Write-Verbose '19.1.1 Set Working Directories' #=================================================================================================== $Info = Join-Path $OSMediaPath 'info' if (!(Test-Path "$Info")) {New-Item "$Info" -ItemType Directory -Force | Out-Null} if (!(Test-Path "$Info\json")) {New-Item "$Info\json" -ItemType Directory -Force | Out-Null} if (!(Test-Path "$Info\logs")) {New-Item "$Info\logs" -ItemType Directory -Force | Out-Null} if (!(Test-Path "$Info\xml")) {New-Item "$Info\xml" -ItemType Directory -Force | Out-Null} $OS = Join-Path $OSMediaPath 'OS' if (!(Test-Path "$OS")) {New-Item "$OS" -ItemType Directory -Force | Out-Null} $WinPE = Join-Path $OSMediaPath 'WinPE' if (!(Test-Path "$WinPE")) {New-Item "$WinPE" -ItemType Directory -Force | Out-Null} $PEInfo = Join-Path $WinPE 'info' if (!(Test-Path "$PEInfo")) {New-Item "$PEInfo" -ItemType Directory -Force | Out-Null} if (!(Test-Path "$PEInfo\json")) {New-Item "$PEInfo\json" -ItemType Directory -Force | Out-Null} if (!(Test-Path "$PEInfo\logs")) {New-Item "$PEInfo\logs" -ItemType Directory -Force | Out-Null} if (!(Test-Path "$PEInfo\xml")) {New-Item "$PEInfo\xml" -ItemType Directory -Force | Out-Null} #=================================================================================================== Write-Verbose '19.1.1 Export RegCurrentVersion' #=================================================================================================== $RegCurrentVersion | Out-File "$Info\CurrentVersion.txt" $RegCurrentVersion | Out-File "$OSMediaPath\CurrentVersion.txt" $RegCurrentVersion | Out-File "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-CurrentVersion.txt" $RegCurrentVersion | Export-Clixml -Path "$Info\xml\CurrentVersion.xml" $RegCurrentVersion | Export-Clixml -Path "$Info\xml\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-CurrentVersion.xml" $RegCurrentVersion | ConvertTo-Json | Out-File "$Info\json\CurrentVersion.json" $RegCurrentVersion | ConvertTo-Json | Out-File "$Info\json\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-CurrentVersion.json" #=================================================================================================== Write-Verbose '19.1.1 Start Transcript' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray $ScriptName = $MyInvocation.MyCommand.Name $LogName = "$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-$ScriptName.log" Start-Transcript -Path (Join-Path "$Info\logs" $LogName) #=================================================================================================== Write-Verbose '19.1.1 OSMedia Information' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "OSMedia Information" -ForegroundColor Green Write-Host "-OSMediaName: $OSMediaName" -ForegroundColor Yellow Write-Host "-OSMediaPath: $OSMediaPath" -ForegroundColor Yellow Write-Host "-OS: $OS" Write-Host "-WinPE: $WinPE" Write-Host "-Info: $Info" Write-Host "-Logs: $Info\logs" #=================================================================================================== Write-Verbose '19.1.1 Windows Image Information' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Image Information" -ForegroundColor Green Write-Host "Source Path: $OSSourcePath" Write-Host "-Image File: $OSImagePath" Write-Host "-Image Index: $OSImageIndex" Write-Host "-Name: $OSImageName" Write-Host "-Description: $OSImageDescription" Write-Host "-Architecture: $OSArchitecture" Write-Host "-Edition: $OSEditionID" Write-Host "-Type: $OSInstallationType" Write-Host "-Languages: $OSLanguages" Write-Host "-Build: $OSBuild" Write-Host "-Version: $OSVersion" Write-Host "-SPBuild: $OSSPBuild" Write-Host "-SPLevel: $OSSPLevel" Write-Host "-Bootable: $OSImageBootable" Write-Host "-WimBoot: $OSWIMBoot" Write-Host "-Created Time: $OSCreatedTime" Write-Host "-Modified Time: $OSModifiedTime" Write-Host "-UBR: $UBR" Write-Host "-OSMGuid: $OSMGuid" #=================================================================================================== Write-Verbose '19.1.1 Media: Copy Operating System' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Media: Copy Operating System to $OS" -ForegroundColor Green Copy-Item -Path "$OSSourcePath\*" -Destination "$OS" -Exclude "install.$InstallWimType" -Recurse -Force | Out-Null Get-ChildItem -Recurse -Path "$OS\*" | Set-ItemProperty -Name IsReadOnly -Value $false -ErrorAction SilentlyContinue | Out-Null if ($InstallWimType -eq "esd") { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Export-WindowsImage.log" Write-Verbose "$CurrentLog" Export-WindowsImage -SourceImagePath "$TempESD" -SourceIndex 1 -DestinationImagePath "$OS\sources\install.wim" -LogPath "$CurrentLog" | Out-Null } else { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Export-WindowsImage.log" Write-Verbose "$CurrentLog" Export-WindowsImage -SourceImagePath "$OSImagePath" -SourceIndex $OSImageIndex -DestinationImagePath "$OS\sources\install.wim" -LogPath "$CurrentLog" | Out-Null } #=================================================================================================== Write-Verbose '19.1.1 OSB-AutoExtraFilesBackup' #=================================================================================================== #Write-Host '========================================================================================' -ForegroundColor DarkGray OSB-AutoExtraFilesBackup -OSMediaPath "$OSMediaPath" #=================================================================================================== Write-Verbose '19.1.3 OSB-SessionsCopy' #=================================================================================================== OSB-SessionsCopy -OSMediaPath "$OSMediaPath" #=================================================================================================== Write-Verbose '19.1.1 OSB-OS-Inventory' #=================================================================================================== #Write-Host '========================================================================================' -ForegroundColor DarkGray OSB-OS-Inventory -OSMediaPath "$OSMediaPath" #=================================================================================================== Write-Verbose '19.1.1 OSB-WinPE-ExportWims' #=================================================================================================== #Write-Host '========================================================================================' -ForegroundColor DarkGray OSB-WinPE-ExportWims -OSMediaPath "$OSMediaPath" #=================================================================================================== Write-Verbose '19.1.1 OSB-WinPE-ExportInventory' #=================================================================================================== #Write-Host '========================================================================================' -ForegroundColor DarkGray OSB-WinPE-ExportInventory -OSMediaPath "$OSMediaPath" #=================================================================================================== Write-Verbose '19.1.1 Install.wim: Dismount' #=================================================================================================== #Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Dismount from $MountDirectory" -ForegroundColor Green if ($OSImagePath -like "*.esd") {Remove-Item $TempESD -Force | Out-Null} $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Dismount-WindowsImage.log" Write-Verbose "$CurrentLog" Dismount-WindowsImage -Discard -Path "$MountDirectory" -LogPath "$CurrentLog" | Out-Null #=================================================================================================== Write-Verbose '19.1.1 Install.wim: Export Configuration' #=================================================================================================== #Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Export Configuration to $OSMediaPath\WindowsImage.txt" -ForegroundColor Green $GetWindowsImage = @() $GetWindowsImage = Get-WindowsImage -ImagePath "$OS\sources\install.wim" -Index 1 | Select-Object -Property * Write-Verbose "========== SPBuild: $($GetWindowsImage.Build).$($GetWindowsImage.SPBuild)" if ($OSVersion -like "6.1*") { Write-Verbose '========== Windows 6.1' $UBR = "$($GetWindowsImage.Build).$($GetWindowsImage.SPBuild)" } Write-Verbose "========== UBR: $UBR" $GetWindowsImage | Add-Member -Type NoteProperty -Name "UBR" -Value $UBR $GetWindowsImage | Add-Member -Type NoteProperty -Name "OSMGuid" -Value $OSMGuid $GetWindowsImage | Out-File "$OSMediaPath\WindowsImage.txt" $GetWindowsImage | Out-File "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Get-WindowsImage.txt" $GetWindowsImage | Export-Clixml -Path "$Info\xml\Get-WindowsImage.xml" $GetWindowsImage | Export-Clixml -Path "$Info\xml\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Get-WindowsImage.xml" $GetWindowsImage | ConvertTo-Json | Out-File "$Info\json\Get-WindowsImage.json" $GetWindowsImage | ConvertTo-Json | Out-File "$Info\json\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Get-WindowsImage.json" (Get-Content "$OSMediaPath\WindowsImage.txt") | Where-Object {$_.Trim(" `t")} | Set-Content "$OSMediaPath\WindowsImage.txt" #=================================================================================================== Write-Verbose '19.1.1 Install.wim: Export Image Content' #=================================================================================================== #Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Install.wim: Export Image Content to $Info\Get-WindowsImageContent.txt" -ForegroundColor Green Get-WindowsImageContent -ImagePath "$OS\Sources\install.wim" -Index 1 | Out-File "$Info\Get-WindowsImageContent.txt" #=================================================================================================== Write-Verbose '19.1.1 Export Variables.xml' #=================================================================================================== Get-Variable | Select-Object -Property Name, Value | Export-Clixml "$Info\xml\Variables.xml" Get-Variable | Select-Object -Property Name, Value | ConvertTo-Json | Out-File "$Info\json\Variables.json" #=================================================================================================== Write-Verbose '19.1.1 Show-OSBMediaINFO' #=================================================================================================== if ($MediaINFO.IsPresent) { #Write-Host '========================================================================================' -ForegroundColor DarkGray Show-OSBMediaINFO -FullName $OSMediaPath } #=================================================================================================== Write-Verbose '19.1.1 Stop Transcript' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Stop-Transcript #=================================================================================================== Write-Verbose '19.1.1 New-OSBMediaISO.ps1' #=================================================================================================== if ($MediaISO.IsPresent) { Write-Host '========================================================================================' -ForegroundColor DarkGray New-OSBMediaISO -FullName "$NewOSMediaPath" } #=================================================================================================== Write-Verbose '19.1.1 Update-OSMedia' #=================================================================================================== if ($UpdateOSMedia.IsPresent) { if ($OSMajorVersion -eq '10') { Write-Verbose "Update-OSMedia -Name $OSMediaName -DownloadUpdates -Execute" if ($MediaISO.IsPresent) { Update-OSMedia -Name "$OSMediaName" -DownloadUpdates -Execute -ISO } else { Update-OSMedia -Name "$OSMediaName" -DownloadUpdates -Execute } } else { Write-Verbose "Update-OSMedia: Unsupported Operating System Version $OSMajorVersion" Write-Warning "Update-OSMedia is not supported by this Operating System" } } #=================================================================================================== } } END { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) END" -ForegroundColor Green } } |