diff --git a/functions/private/Invoke-MicroWin-Helper.ps1 b/functions/private/Invoke-MicroWin-Helper.ps1 index 1fdb58ea..afcf9080 100644 --- a/functions/private/Invoke-MicroWin-Helper.ps1 +++ b/functions/private/Invoke-MicroWin-Helper.ps1 @@ -18,28 +18,23 @@ function Test-CompatibleImage() { <# .SYNOPSIS - Checks the version of a Windows image and determines whether or not it is compatible depending on the Major property + Checks the version of a Windows image and determines whether or not it is compatible with a specific feature depending on a desired version - .PARAMETER imgVersion - The version of the Windows image + .PARAMETER Name + imgVersion - The version of the Windows image + desiredVersion - The version to compare the image version with #> param ( - [Parameter(Mandatory = $true)] [string] $imgVersion + [Parameter(Mandatory = $true, Position=0)] [string] $imgVersion, + [Parameter(Mandatory = $true, Position=1)] [Version] $desiredVersion ) try { $version = [Version]$imgVersion - if ($version.Major -ge 10) - { - return $True - } - else - { - return $False - } + return $version -ge $desiredVersion } catch { return $False } @@ -247,7 +242,7 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw foreach($itemToDelete in $itemsToDelete) { - $status = "Deleteing $($itemToDelete)" + $status = "Deleting $($itemToDelete)" Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100) if (Test-Path -Path "$($itemToDelete)" -PathType Container) @@ -321,7 +316,7 @@ function New-Unattend { - + <#REPLACEME#> @@ -362,6 +357,26 @@ function New-Unattend { '@ + $specPass = @' + + + 0 + + + false + + +'@ + if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,22000,1))) -eq $false) + { + # Replace the placeholder text with an empty string to make it valid for Windows 10 Setup + $unattend = $unattend.Replace("<#REPLACEME#>", "").Trim() + } + else + { + # Replace the placeholder text with the Specialize pass + $unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim() + } $unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force } diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 8106ab9c..cb304dcc 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -60,7 +60,7 @@ public class PowerManagement { $imgVersion = (Get-WindowsImage -ImagePath $mountDir\sources\install.wim -Index $index).Version # Detect image version to avoid performing MicroWin processing on Windows 8 and earlier - if ((Test-CompatibleImage $imgVersion) -eq $false) + if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,10240,0))) -eq $false) { $msg = "This image is not compatible with MicroWin processing. Make sure it isn't a Windows 8 or earlier image." $dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers." diff --git a/winutil.ps1 b/winutil.ps1 index 0ecc36f8..1f9e5464 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -10,7 +10,7 @@ Author : Chris Titus @christitustech Runspace Author: @DeveloperDurp GitHub : https://github.com/ChrisTitusTech - Version : 24.02.08 + Version : 24.02.09 #> param ( [switch]$Debug, @@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "24.02.08" +$sync.version = "24.02.09" $sync.configs = @{} $sync.ProcessRunning = $false @@ -626,28 +626,23 @@ function Test-CompatibleImage() { <# .SYNOPSIS - Checks the version of a Windows image and determines whether or not it is compatible depending on the Major property + Checks the version of a Windows image and determines whether or not it is compatible with a specific feature depending on a desired version - .PARAMETER imgVersion - The version of the Windows image + .PARAMETER Name + imgVersion - The version of the Windows image + desiredVersion - The version to compare the image version with #> param ( - [Parameter(Mandatory = $true)] [string] $imgVersion + [Parameter(Mandatory = $true, Position=0)] [string] $imgVersion, + [Parameter(Mandatory = $true, Position=1)] [Version] $desiredVersion ) try { $version = [Version]$imgVersion - if ($version.Major -ge 10) - { - return $True - } - else - { - return $False - } + return $version -ge $desiredVersion } catch { return $False } @@ -855,7 +850,7 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw foreach($itemToDelete in $itemsToDelete) { - $status = "Deleteing $($itemToDelete)" + $status = "Deleting $($itemToDelete)" Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100) if (Test-Path -Path "$($itemToDelete)" -PathType Container) @@ -929,7 +924,7 @@ function New-Unattend { - + <#REPLACEME#> @@ -970,6 +965,26 @@ function New-Unattend { '@ + $specPass = @' + + + 0 + + + false + + +'@ + if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,22000,1))) -eq $false) + { + # Replace the placeholder text with an empty string to make it valid for Windows 10 Setup + $unattend = $unattend.Replace("<#REPLACEME#>", "").Trim() + } + else + { + # Replace the placeholder text with the Specialize pass + $unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim() + } $unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force } @@ -3305,7 +3320,7 @@ public class PowerManagement { $imgVersion = (Get-WindowsImage -ImagePath $mountDir\sources\install.wim -Index $index).Version # Detect image version to avoid performing MicroWin processing on Windows 8 and earlier - if ((Test-CompatibleImage $imgVersion) -eq $false) + if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,10240,0))) -eq $false) { $msg = "This image is not compatible with MicroWin processing. Make sure it isn't a Windows 8 or earlier image." $dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."