Skip to content

Commit

Permalink
Updated to build 4.0.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
DrEmpiricism committed Oct 7, 2020
1 parent 9f964f3 commit 9971c69
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 67 deletions.
17 changes: 10 additions & 7 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# ChangeLog #

## Build 4.0.1.6 (10-06-2020)

- Added support for the SWM (split Windows image) file type.
- If the source image is a SWM file, only the first SWM file needs passed to Optimize-Offline. It will recursively copy all additional SWM files. Likewise, the SWM files do not need to be named 'install.swm,' etc. Do note that in order to use a SWM file as the source image, all of the SWM files must be in their own directory. For example, if there are three SWM files named 'test.swm,' 'test2.swm,' 'test3.swm,' then all three of these SWM files must be in their own directory in order for Optimize-Offline to recognize them as split images from the same WIM file.
- Corrected some registry vales that contained an invalid hive mount point.
- Updated the Microsoft Edge Chromium package for Windows 10 builds 19041+.
- Updated the Windows Store bundle packages.
- The MAML XML external help file and manifest data have been updated.
- Multiple code improvements across the framework.

## Build 4.0.1.5 (09-17-2020) ##

- Fixed an error where the metadata for the image would not be returned if both the -DaRT and -Additional parameters were omitted.
Expand Down Expand Up @@ -39,10 +49,3 @@
- The Start-Optimize call script and Resource Functions have been updated.
- The MAML XML external help file and manifest data have been updated.
- There have been additional offline process code changes to reflect the aforementioned updates.

## Build 4.0.1.1 (06-12-2020) ##

- Updated multiple Resource Functions.
- Added a requirement check for PowerShell version 5.
- Updated the registry settings that restore the default Windows Photo Viewer.
- Updated the Windows Store bundle packages.
4 changes: 2 additions & 2 deletions Optimize-Offline.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@{
GUID = '86c4db30-1a45-43c7-a96b-46d2a1d84671'
RootModule = 'Optimize-Offline.psm1'
ModuleVersion = '4.0.1.5'
ModuleVersion = '4.0.1.6'
Author = 'Ben White'
Copyright = '(c) 2020. All rights reserved.'
Description = 'The Optimize-Offline module enables the offline optimizing of Windows 10 image (WIM/ESD) files for optimal runtime environments.'
Expand All @@ -30,7 +30,7 @@
CmdletsToExport = @()
PrivateData = @{
PSData = @{
Tags = @('Image Optimization', 'WIM Optimization', 'Offline Windows Image', 'Offline Servicing', 'Offline Imaging', 'WIM', 'ESD', 'Windows 10', 'LTSC', 'Enterprise', '19H1', '19H2', '20H1', '20H2', 'Deployment', 'Debloat', 'DISM', 'PSModule')
Tags = @('Image Optimization', 'WIM Optimization', 'Offline Windows Image', 'Offline Servicing', 'Offline Imaging', 'WIM', 'SWM', 'ESD', 'Windows 10', 'LTSC', 'Enterprise', '19H1', '19H2', '20H1', '20H2', 'Deployment', 'Debloat', 'DISM', 'PSModule')
LicenseUri = 'https://github.com/DrEmpiricism/Optimize-Offline/blob/master/LICENSE'
ProjectUri = 'https://github.com/DrEmpiricism/Optimize-Offline'
ReleaseNotes = 'https://github.com/DrEmpiricism/Optimize-Offline/blob/master/ChangeLog.md'
Expand Down
127 changes: 74 additions & 53 deletions Optimize-Offline.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
Created on: 11/20/2019 11:53 AM
Created by: BenTheGreat
Filename: Optimize-Offline.psm1
Version: 4.0.1.5
Last updated: 09/17/2020
Version: 4.0.1.6
Last updated: 10/06/2020
-------------------------------------------------------------------------
Module Name: Optimize-Offline
===========================================================================
Expand All @@ -25,9 +25,9 @@ Function Optimize-Offline
(
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
HelpMessage = 'The path to a Windows 10 Installation Media ISO, Windows 10 WIM or Windows 10 ESD file.')]
HelpMessage = 'The full path to a Windows 10 Installation Media ISO, or a Windows 10 WIM, SWM or ESD file.')]
[ValidateScript( {
If ($PSItem.Exists -and $PSItem.Extension -eq '.ISO' -or $PSItem.Extension -eq '.WIM' -or $PSItem.Extension -eq '.ESD') { $true }
If ($PSItem.Exists -and $PSItem.Extension -eq '.ISO' -or $PSItem.Extension -eq '.WIM' -or $PSItem.Extension -eq '.SWM' -or $PSItem.Extension -eq '.ESD') { $true }
Else { Throw ('Invalid source path: "{0}"' -f $PSItem.FullName) }
})]
[IO.FileInfo]$SourcePath,
Expand Down Expand Up @@ -103,7 +103,7 @@ Function Optimize-Offline
{
$ISOMount = (Mount-DiskImage -ImagePath $SourcePath.FullName -StorageType ISO -PassThru | Get-Volume).DriveLetter + ':'
[Void](Get-PSDrive)
If (!(Get-ChildItem -Path (GetPath -Path $ISOMount -Child sources) -Filter install.* -File))
If (!(Get-ChildItem -Path (GetPath -Path $ISOMount -Child sources) -Filter install* -File))
{
$PSCmdlet.WriteWarning($OptimizeData.InvalidWindowsInstallMedia -f $SourcePath.Name)
Do
Expand All @@ -123,49 +123,72 @@ Function Optimize-Offline
$ISOExport = $ISOMedia.FullName + $Item.FullName.Replace($ISOMount, $null)
Copy-Item -Path $Item.FullName -Destination $ISOExport
}
Get-ChildItem -Path (GetPath -Path $ISOMedia.FullName -Child sources) -Filter install.* -File | Move-Item -Destination $ImageFolder -PassThru | Set-ItemProperty -Name IsReadOnly -Value $false
If ($DaRT -or $Additional)
Do
{
If ($DaRT.Contains('Setup') -or ($Additional.Drivers -and (Get-ChildItem -Path $OptimizeOffline.BootDrivers -Include *.inf -Recurse -Force)))
[Void](Dismount-DiskImage -ImagePath $SourcePath.FullName)
}
While ((Get-DiskImage -ImagePath $SourcePath.FullName).Attached -eq $true)
If ((Get-ChildItem -Path (GetPath -Path $ISOMedia.FullName -Child sources) -Filter install* -File | Measure-Object).Count -gt 1 -and (Get-ChildItem -Path (GetPath -Path $ISOMedia.FullName -Child sources) -Filter install* -File | Select-Object -First 1).Extension -eq '.SWM')
{
Try
{
Get-ChildItem -Path (GetPath -Path $ISOMedia.FullName -Child sources) -Filter boot.* -File | Move-Item -Destination $ImageFolder -PassThru | Set-ItemProperty -Name IsReadOnly -Value $false
$InstallWim = Get-ChildItem -Path (GetPath -Path $ISOMedia.FullName -Child sources) -Filter install* -File | Select-Object -First 1 | Move-Item -Destination $ImageFolder -PassThru -ErrorAction Stop | Set-ItemProperty -Name IsReadOnly -Value $false -PassThru | Get-Item | Select-Object -ExpandProperty FullName
$SwmFiles = Get-ChildItem -Path (GetPath -Path $ISOMedia.FullName -Child sources) -Filter install* -File | Move-Item -Destination $ImageFolder -PassThru -ErrorAction Stop | Set-ItemProperty -Name IsReadOnly -Value $false -PassThru | Get-Item | Select-Object -ExpandProperty FullName
}
Catch [Management.Automation.ItemNotFoundException] { Break }
}
Do
Else
{
[Void](Dismount-DiskImage -ImagePath $SourcePath.FullName)
Try { $InstallWim = Get-ChildItem -Path (GetPath -Path $ISOMedia.FullName -Child sources) -Filter install.* -File | Move-Item -Destination $ImageFolder -PassThru -ErrorAction Stop | Set-ItemProperty -Name IsReadOnly -Value $false -PassThru | Get-Item | Select-Object -ExpandProperty FullName }
Catch [Management.Automation.ItemNotFoundException] { Break }
}
If ($DaRT -or $Additional.ContainsValue($true))
{
If ($DaRT.Contains('Setup') -or ($Additional.Drivers -and (Get-ChildItem -Path $OptimizeOffline.BootDrivers -Include *.inf -Recurse -Force)))
{
Try { $BootWim = Get-ChildItem -Path (GetPath -Path $ISOMedia.FullName -Child sources) -Filter boot.* -File | Move-Item -Destination $ImageFolder -PassThru -ErrorAction Stop | Set-ItemProperty -Name IsReadOnly -Value $false -PassThru | Get-Item | Select-Object -ExpandProperty FullName }
Catch [Management.Automation.ItemNotFoundException] { Break }
}
}
While ((Get-DiskImage -ImagePath $SourcePath.FullName).Attached -eq $true)
Break
}
Default
{
$Host.UI.RawUI.WindowTitle = ($OptimizeData.CopyingImage -f $SourcePath.Extension.TrimStart('.').ToUpper(), $SourcePath.DirectoryName)
Write-Host ($OptimizeData.CopyingImage -f $SourcePath.Extension.TrimStart('.').ToUpper(), $SourcePath.DirectoryName) -ForegroundColor Cyan
Get-ChildItem -Path $SourcePath.FullName -Filter $SourcePath.Name | Copy-Item -Destination $ImageFolder -PassThru | Rename-Item -NewName ('install' + $SourcePath.Extension) -PassThru | Set-ItemProperty -Name IsReadOnly -Value $false
Try { $InstallWim = Get-ChildItem -Path $SourcePath.FullName -Filter $SourcePath.Name | Copy-Item -Destination $ImageFolder -PassThru -ErrorAction Stop | Rename-Item -NewName ('install' + $SourcePath.Extension) -PassThru | Set-ItemProperty -Name IsReadOnly -Value $false -PassThru | Get-Item | Select-Object -ExpandProperty FullName }
Catch [Management.Automation.ItemNotFoundException] { Break }
If ($SourcePath.Extension -eq '.SWM')
{
Try { $SwmFiles = Get-ChildItem -Path $SourcePath.DirectoryName -Filter "$($SourcePath.BaseName)*$($SourcePath.Extension)" -Exclude $SourcePath.Name -Recurse | Where-Object -Property Name -Like "$($SourcePath.BaseName)*.swm" | Copy-Item -Destination $ImageFolder -PassThru -ErrorAction Stop | Set-ItemProperty -Name IsReadOnly -Value $false -PassThru }
Catch [Management.Automation.ItemNotFoundException] { Break }
$I = 2
$SwmFiles = Get-ChildItem -Path $ImageFolder -Include $SwmFiles.PSChildName -File -Recurse | ForEach-Object -Process { Rename-Item -Path $PSItem -NewName ('install{0:D1}.swm' -f $I++) -PassThru }
}
If ($ISO) { Remove-Variable -Name ISO }
Break
}
}

If (Get-ChildItem -Path $ImageFolder -Filter install.* -File)
If ([IO.File]::Exists($InstallWim))
{
$InstallWim = Get-ChildItem -Path $ImageFolder -Filter install.* | Select-Object -ExpandProperty FullName
If ([IO.Path]::GetExtension($InstallWim) -eq '.ESD') { $DynamicParams.ESD = $true }
Switch ([IO.Path]::GetExtension($InstallWim))
{
'.ESD' { $DynamicParams.ESD = $true; Break }
'.SWM' { $DynamicParams.SWM = $true; Break }
Default { $DynamicParams.WIM = $true; Break }
}
If ($BootWim)
{
If ([IO.File]::Exists($BootWim)) { $DynamicParams.BootImage = $true }
}
}
Else
{
$PSCmdlet.WriteWarning($OptimizeData.FailedToReturnInstallImage -f $ImageFolder)
$TempDirectory | Purge
Break
}

If (Get-ChildItem -Path $ImageFolder -Filter boot.* -File)
{
$BootWim = Get-ChildItem -Path $ImageFolder -Filter boot.wim | Select-Object -ExpandProperty FullName
$DynamicParams.BootImage = $true
}

#endregion Media Export

#region Image and Metadata Validation
Expand Down Expand Up @@ -228,7 +251,7 @@ Function Optimize-Offline
If ($MicrosoftEdge.IsPresent -and $InstallInfo.Build -ge '18362')
{
If ($InstallInfo.Build -eq '18362') { $EdgeChromiumUBR = 833 }
Else { $EdgeChromiumUBR = 261 }
Else { $EdgeChromiumUBR = 479 }
}
Else { $MicrosoftEdge = ![Switch]::Present }
}
Expand All @@ -251,25 +274,26 @@ Function Optimize-Offline
#endregion Image and Metadata Validation

#region Image Preparation
If ($DynamicParams.ESD)
If (!$DynamicParams.WIM)
{
$ExportToWimParams = @{
SourceImagePath = $InstallWim
SourceIndex = $ImageIndex
DestinationImagePath = '{0}\install.wim' -f $WorkFolder
CheckIntegrity = $true
ScratchDirectory = $ScratchFolder
LogPath = $DISMLog
LogLevel = 1
ErrorAction = 'Stop'
}
If ($DynamicParams.ESD) { $ExportToWimParams.CompressionType = 'Maximum' }
Else { $ExportToWimParams.SplitImageFilePattern = ('{0}\install*.swm' -f $ImageFolder) }
Try
{
$ExportToWimParams = @{
SourceImagePath = $InstallWim
SourceIndex = $ImageIndex
DestinationImagePath = '{0}\install.wim' -f $WorkFolder
CompressionType = 'Maximum'
CheckIntegrity = $true
ScratchDirectory = $ScratchFolder
LogPath = $DISMLog
LogLevel = 1
ErrorAction = 'Stop'
}
$Host.UI.RawUI.WindowTitle = ($OptimizeData.ExportingInstallToWim -f (GetPath -Path $InstallWim -Split Leaf), (GetPath -Path ([IO.Path]::ChangeExtension($InstallWim, '.wim')) -Split Leaf))
Write-Host ($OptimizeData.ExportingInstallToWim -f (GetPath -Path $InstallWim -Split Leaf), (GetPath -Path ([IO.Path]::ChangeExtension($InstallWim, '.wim')) -Split Leaf)) -ForegroundColor Cyan
[Void](Export-WindowsImage @ExportToWimParams)
If ($ImageIndex -ne 1) { $ImageIndex = 1 }
$ImageIndex = 1
}
Catch
{
Expand All @@ -280,8 +304,8 @@ Function Optimize-Offline
Finally
{
$InstallWim | Purge
If ($DynamicParams.SWM) { $SwmFiles | Purge }
}

Try
{
$InstallWim = Get-ChildItem -Path $WorkFolder -Filter install.wim | Move-Item -Destination $ImageFolder -Force -PassThru | Select-Object -ExpandProperty FullName
Expand All @@ -295,6 +319,8 @@ Function Optimize-Offline
}
}

If ($Global:Error.Count -ne 0) { $Global:Error.Clear() }

Try
{
Log ($OptimizeData.SupportedImageBuild -f $InstallInfo.Build)
Expand All @@ -313,15 +339,17 @@ Function Optimize-Offline
}
Log ($OptimizeData.MountingImage -f $InstallInfo.Name)
[Void](Mount-WindowsImage @MountInstallParams)
$DynamicParams.InstallImage = $true
RegHives -Load
Get-ItemProperty -Path "HKLM:\WIM_HKLM_SOFTWARE\Microsoft\Windows NT\CurrentVersion" | Export-DataFile -File CurrentVersion
RegHives -Unload
}
Catch
{
Log ($OptimizeData.FailedMountingImage -f $InstallInfo.Name) -Type Error -ErrorRecord $Error[0]
Stop-Optimize
}

If ($DaRT -or $Additional)
If ($DaRT -or $Additional.ContainsValue($true))
{
If ($DaRT.Contains('Recovery') -or ($Additional.Drivers -and (Get-ChildItem -Path $OptimizeOffline.RecoveryDrivers -Include *.inf -Recurse -Force)))
{
Expand All @@ -334,13 +362,6 @@ Function Optimize-Offline
}
}

If ($DynamicParams.InstallImage)
{
RegHives -Load
Get-ItemProperty -Path "HKLM:\WIM_HKLM_SOFTWARE\Microsoft\Windows NT\CurrentVersion" | Export-DataFile -File CurrentVersion
RegHives -Unload
}

If ($DynamicParams.BootImage)
{
Try
Expand Down Expand Up @@ -1108,12 +1129,12 @@ Function Optimize-Offline
RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\WOW6432Node\Policies\Microsoft\MicrosoftEdge\Addons" -Name "FlashPlayerEnabled" -Value 0 -Type DWord
RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\MicrosoftEdge\BooksLibrary" -Name "EnableExtendedBooksTelemetry" -Value 0 -Type DWord
RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\WOW6432Node\Policies\Microsoft\MicrosoftEdge\BooksLibrary" -Name "EnableExtendedBooksTelemetry" -Value 0 -Type DWord
RegKey -Path "HKCU:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main" -Name "DoNotTrack" -Value 1 -Type DWord
RegKey -Path "HKCU:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main" -Name "ShowSearchSuggestionsGlobal" -Value 0 -Type DWord
RegKey -Path "HKCU:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main" -Name "IE10TourShown" -Value 1 -Type DWord
RegKey -Path "HKCU:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main" -Name "DisallowDefaultBrowserPrompt" -Value 1 -Type DWord
RegKey -Path "HKCU:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\FlipAhead" -Name "FPEnabled" -Value 0 -Type DWord
RegKey -Path "HKCU:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\FirstRun" -Name "LastFirstRunVersionDelivered" -Value 1 -Type DWord
RegKey -Path "HKLM:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main" -Name "DoNotTrack" -Value 1 -Type DWord
RegKey -Path "HKLM:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main" -Name "ShowSearchSuggestionsGlobal" -Value 0 -Type DWord
RegKey -Path "HKLM:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main" -Name "IE10TourShown" -Value 1 -Type DWord
RegKey -Path "HKLM:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main" -Name "DisallowDefaultBrowserPrompt" -Value 1 -Type DWord
RegKey -Path "HKLM:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\FlipAhead" -Name "FPEnabled" -Value 0 -Type DWord
RegKey -Path "HKLM:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\FirstRun" -Name "LastFirstRunVersionDelivered" -Value 1 -Type DWord
RegKey -Path "HKLM:\WIM_HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\ServiceUI" -Name "EnableCortana" -Value 0 -Type DWord
If ($DynamicParams.LTSC -and $DynamicParams.SecHealthUI)
{
Expand Down
4 changes: 2 additions & 2 deletions docs/Optimize-Offline-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Optimize-Offline [-SourcePath] <FileInfo> [[-WindowsApps] <String>] [-SystemApps
```

## DESCRIPTION
The Optimize-Offline module enables the offline optimization of Windows 10 image (WIM/ESD) files to customize runtime environments.
The Optimize-Offline module enables the offline optimization of Windows 10 image (WIM/SWM/ESD) files to customize runtime environments.

Optimize-Offline expands the user experience by eliminating unnecessary bloat, enhancing privacy, improving aesthetics and increasing system performance.

Expand All @@ -46,7 +46,7 @@ This command starts optimizing an image by manually passing parameters to the mo
## PARAMETERS

### -SourcePath
The path to a Windows 10 Installation Media ISO, Windows 10 WIM or Windows 10 ESD file.
The full path to a Windows 10 Installation Media ISO, or a Windows 10 WIM, SWM or ESD file.

```yaml
Type: FileInfo
Expand Down
Loading

0 comments on commit 9971c69

Please sign in to comment.