Skip to content

Commit

Permalink
Continue conversion
Browse files Browse the repository at this point in the history
Began 2nd stage of DISM command conversion. Almost all commands have been replaced by cmdlets
  • Loading branch information
CodingWonders committed Mar 30, 2024
1 parent 4a7c8a3 commit 98dbe8e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
18 changes: 10 additions & 8 deletions functions/private/Invoke-MicroWin-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,27 @@ function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender
Remove-Features -keepDefender:$false
#>
$appxlist = dism /English /image:$scratchDir /Get-Features | Select-String -Pattern "Feature Name : " -CaseSensitive -SimpleMatch
$appxlist = $appxlist -split "Feature Name : " | Where-Object {$_}
#$featlist = dism /English /image:$scratchDir /Get-Features | Select-String -Pattern "Feature Name : " -CaseSensitive -SimpleMatch
#$featlist = $featlist -split "Feature Name : " | Where-Object {$_}
$featlist = (Get-WindowsOptionalFeature -Path $scratchDir).FeatureName
if ($dumpFeatures)
{
$appxlist > allfeaturesdump.txt
$featlist > allfeaturesdump.txt
}

$appxlist = $appxlist | Where-Object {
$featlist = $featlist | Where-Object {
$_ -NotLike "*Printing*" -AND
$_ -NotLike "*TelnetClient*" -AND
$_ -NotLike "*PowerShell*" -AND
$_ -NotLike "*NetFx*"
}

if ($keepDefender) { $appxlist = $appxlist | Where-Object { $_ -NotLike "*Defender*" }}
if ($keepDefender) { $featlist = $featlist | Where-Object { $_ -NotLike "*Defender*" }}

foreach($feature in $appxlist)
foreach($feature in $featlist)
{
$status = "Removing feature $feature"
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$appxlist.Count*100)
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$featlist.Count*100)
Write-Debug "Removing feature $feature"
# dism /image:$scratchDir /Disable-Feature /FeatureName:$feature /Remove /NoRestart > $null
}
Expand Down Expand Up @@ -167,7 +168,8 @@ function Remove-ProvisionedPackages([switch] $keepSecurity = $false)
{
$status = "Removing Provisioned $($appx.PackageName)"
Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100)
dism /English /image:$scratchDir /Remove-ProvisionedAppxPackage /PackageName:$($appx.PackageName) /NoRestart
#dism /English /image:$scratchDir /Remove-ProvisionedAppxPackage /PackageName:$($appx.PackageName) /NoRestart
Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName
}
Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed
}
Expand Down
3 changes: 2 additions & 1 deletion functions/public/Invoke-WPFMicrowin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public class PowerManagement {
if (Test-Path $driverPath)
{
Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) "
dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host
#dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host
Add-WindowsDriver -Path "$scratchDir" -Recurse -Driver "$driverPath"
}
else
{
Expand Down
21 changes: 12 additions & 9 deletions winutil.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -850,26 +850,27 @@ function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender
Remove-Features -keepDefender:$false

#>
$appxlist = dism /English /image:$scratchDir /Get-Features | Select-String -Pattern "Feature Name : " -CaseSensitive -SimpleMatch
$appxlist = $appxlist -split "Feature Name : " | Where-Object {$_}
#$featlist = dism /English /image:$scratchDir /Get-Features | Select-String -Pattern "Feature Name : " -CaseSensitive -SimpleMatch
#$featlist = $featlist -split "Feature Name : " | Where-Object {$_}
$featlist = (Get-WindowsOptionalFeature -Path $scratchDir).FeatureName
if ($dumpFeatures)
{
$appxlist > allfeaturesdump.txt
$featlist > allfeaturesdump.txt
}

$appxlist = $appxlist | Where-Object {
$featlist = $featlist | Where-Object {
$_ -NotLike "*Printing*" -AND
$_ -NotLike "*TelnetClient*" -AND
$_ -NotLike "*PowerShell*" -AND
$_ -NotLike "*NetFx*"
}

if ($keepDefender) { $appxlist = $appxlist | Where-Object { $_ -NotLike "*Defender*" }}
if ($keepDefender) { $featlist = $featlist | Where-Object { $_ -NotLike "*Defender*" }}

foreach($feature in $appxlist)
foreach($feature in $featlist)
{
$status = "Removing feature $feature"
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$appxlist.Count*100)
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$featlist.Count*100)
Write-Debug "Removing feature $feature"
# dism /image:$scratchDir /Disable-Feature /FeatureName:$feature /Remove /NoRestart > $null
}
Expand Down Expand Up @@ -963,7 +964,8 @@ function Remove-ProvisionedPackages([switch] $keepSecurity = $false)
{
$status = "Removing Provisioned $($appx.PackageName)"
Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100)
dism /English /image:$scratchDir /Remove-ProvisionedAppxPackage /PackageName:$($appx.PackageName) /NoRestart
#dism /English /image:$scratchDir /Remove-ProvisionedAppxPackage /PackageName:$($appx.PackageName) /NoRestart
Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName
}
Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed
}
Expand Down Expand Up @@ -3694,7 +3696,8 @@ public class PowerManagement {
if (Test-Path $driverPath)
{
Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) "
dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host
#dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host
Add-WindowsDriver -Path "$scratchDir" -Recurse -Driver "$driverPath"
}
else
{
Expand Down

0 comments on commit 98dbe8e

Please sign in to comment.