diff --git a/Compile.ps1 b/Compile.ps1 index d17b15af..69265228 100644 --- a/Compile.ps1 +++ b/Compile.ps1 @@ -23,8 +23,9 @@ Get-ChildItem .\functions -Recurse -File | ForEach-Object { Get-ChildItem .\xaml | ForEach-Object { $xaml = (Get-Content $psitem.FullName).replace("'","''") + $newXaml = $xaml -replace 'CTTVersion', (Get-Date -Format 'yy.MM.dd') - Write-output "`$$($psitem.BaseName) = '$xaml'" | Out-File ./$scriptname -Append -Encoding ascii + Write-output "`$$($psitem.BaseName) = '$newXaml'" | Out-File ./$scriptname -Append -Encoding ascii } Get-ChildItem .\config | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object { diff --git a/functions/private/MicroWin-Helper.ps1 b/functions/private/MicroWin-Helper.ps1 index 0291e7e8..5219f1b5 100644 --- a/functions/private/MicroWin-Helper.ps1 +++ b/functions/private/MicroWin-Helper.ps1 @@ -90,8 +90,20 @@ function Remove-Packages Write-Progress -Activity "Removing Apps" -Status "Ready" -Completed } -function Remove-ProvisionedPackages +function Remove-ProvisionedPackages([switch] $keepSecurity = $false) { +<# + + .SYNOPSIS + Removes AppX packages from a Windows image during MicroWin processing + + .PARAMETER Name + keepSecurity - Boolean that determines whether to keep "Microsoft.SecHealthUI" (Windows Security) in the Windows image + + .EXAMPLE + Remove-ProvisionedPackages -keepSecurity:$false + +#> $appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object { $_.PackageName -NotLike "*AppInstaller*" -AND $_.PackageName -NotLike "*Store*" -and @@ -107,6 +119,7 @@ function Remove-ProvisionedPackages if ($?) { + if ($keepSecurity) { $appxProvisionedPackages = $appxProvisionedPackages | Where-Object { $_.PackageName -NotLike "*SecHealthUI*" }} $counter = 0 foreach ($appx in $appxProvisionedPackages) { diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 0b50c9eb..de4da7f2 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -63,7 +63,7 @@ function Invoke-WPFMicrowin { } if (!$keepProvisionedPackages) { - Remove-ProvisionedPackages + Remove-ProvisionedPackages -keepSecurity:$keepDefender } # special code, for some reason when you try to delete some inbox apps diff --git a/winutil.ps1 b/winutil.ps1 index e81ce133..d1534ba5 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.01.02 + Version : 24.01.03 #> Start-Transcript $ENV:TEMP\Winutil.log -Append @@ -22,7 +22,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "24.01.02" +$sync.version = "24.01.03" $sync.configs = @{} $sync.ProcessRunning = $false @@ -1121,8 +1121,20 @@ function Remove-Packages Write-Progress -Activity "Removing Apps" -Status "Ready" -Completed } -function Remove-ProvisionedPackages +function Remove-ProvisionedPackages([switch] $keepSecurity = $false) { +<# + + .SYNOPSIS + Removes AppX packages from a Windows image during MicroWin processing + + .PARAMETER Name + keepSecurity - Boolean that determines whether to keep "Microsoft.SecHealthUI" (Windows Security) in the Windows image + + .EXAMPLE + Remove-ProvisionedPackages -keepSecurity:$false + +#> $appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object { $_.PackageName -NotLike "*AppInstaller*" -AND $_.PackageName -NotLike "*Store*" -and @@ -1138,6 +1150,7 @@ function Remove-ProvisionedPackages if ($?) { + if ($keepSecurity) { $appxProvisionedPackages = $appxProvisionedPackages | Where-Object { $_.PackageName -NotLike "*SecHealthUI*" }} $counter = 0 foreach ($appx in $appxProvisionedPackages) { @@ -2640,7 +2653,7 @@ function Invoke-WPFMicrowin { } if (!$keepProvisionedPackages) { - Remove-ProvisionedPackages + Remove-ProvisionedPackages -keepSecurity:$keepDefender } # special code, for some reason when you try to delete some inbox apps @@ -4263,12 +4276,15 @@ $inputXML = ' +