|
1 | 1 | <#PSScriptInfo |
2 | | -.VERSION 3.3.0 |
| 2 | +.VERSION 3.3.1 |
3 | 3 | .GUID 39efc9c5-7b51-4d1f-b650-0f3818e5327a |
4 | 4 | .AUTHOR Michael Niehaus |
5 | 5 | .COMPANYNAME |
@@ -33,6 +33,7 @@ v3.1.0 - 2025-06-01 - Modified WinGet logic, switched to PowerShell for creating |
33 | 33 | v3.2.0 - 2025-07-15 - Various fixes (start menu layout, apps, etc.) |
34 | 34 | v3.2.1 - 2025-07-15 - Updated makeapps.cmd to use PowerShell 7 |
35 | 35 | v3.3.0 - 2025-09-20 - Added bookmark cleanup for Edge, Chrome. Fixed start menu config. Added Try/catch/finally. Added OOBE check. |
| 36 | +v3.3.1 - 2025-10-10 - Minor bug fixes |
36 | 37 | #> |
37 | 38 |
|
38 | 39 | [CmdletBinding()] |
@@ -399,29 +400,40 @@ try |
399 | 400 |
|
400 | 401 | # Step 11A: Disable Optional features |
401 | 402 | if ($config.Config.DisableOptionalFeatures.Feature.Count -gt 0) { |
402 | | - $EnabledOptionalFeatures = Get-WindowsOptionalFeature -Online | Where-Object { $_.State -eq "Enabled" } |
403 | | - foreach ($EnabledFeature in $EnabledOptionalFeatures) { |
404 | | - if ($config.Config.DisableOptionalFeatures.Feature -contains $EnabledFeature.FeatureName) { |
405 | | - Log "Disabling Optional Feature: $($EnabledFeature.FeatureName)" |
406 | | - try { |
407 | | - Disable-WindowsOptionalFeature -Online -FeatureName $EnabledFeature.FeatureName -NoRestart | Out-Null |
| 403 | + try { |
| 404 | + $EnabledOptionalFeatures = Get-WindowsOptionalFeature -Online | Where-Object { $_.State -eq "Enabled" } |
| 405 | + foreach ($EnabledFeature in $EnabledOptionalFeatures) { |
| 406 | + if ($config.Config.DisableOptionalFeatures.Feature -contains $EnabledFeature.FeatureName) { |
| 407 | + Log "Disabling Optional Feature: $($EnabledFeature.FeatureName)" |
| 408 | + try { |
| 409 | + Disable-WindowsOptionalFeature -Online -FeatureName $EnabledFeature.FeatureName -NoRestart | Out-Null |
| 410 | + } |
| 411 | + catch {} |
408 | 412 | } |
409 | | - catch {} |
410 | 413 | } |
| 414 | + } |
| 415 | + catch { |
| 416 | + Log "Unexpected error querying Windows optional features: $_" |
411 | 417 | } |
412 | 418 | } |
413 | 419 |
|
414 | 420 | # Step 11B: Remove Windows Capabilities |
415 | 421 | if ($config.Config.RemoveCapability.Capability.Count -gt 0) { |
416 | | - $InstalledCapabilities = Get-WindowsCapability -Online | Where-Object { $_.State -eq "Installed" } |
417 | | - foreach ($InstalledCapability in $InstalledCapabilities) { |
418 | | - if ($config.Config.RemoveCapability.Capability -contains $InstalledCapability.Name.Split("~")[0]) { |
419 | | - Log "Removing Windows Capability: $($InstalledCapability.Name)" |
420 | | - try { |
421 | | - Remove-WindowsCapability -Online -Name $InstalledCapability.Name | Out-Null |
| 422 | + try { |
| 423 | + $InstalledCapabilities = Get-WindowsCapability -Online | Where-Object { $_.State -eq "Installed" } |
| 424 | + foreach ($InstalledCapability in $InstalledCapabilities) { |
| 425 | + if ($config.Config.RemoveCapability.Capability -contains $InstalledCapability.Name.Split("~")[0]) { |
| 426 | + Log "Removing Windows Capability: $($InstalledCapability.Name)" |
| 427 | + try { |
| 428 | + Remove-WindowsCapability -Online -Name $InstalledCapability.Name | Out-Null |
| 429 | + } |
| 430 | + catch { |
| 431 | + Log " Unable to remove Windows capability: $_" |
| 432 | + } |
422 | 433 | } |
423 | | - catch {} |
424 | 434 | } |
| 435 | + } catch { |
| 436 | + Log "Unexpected error querying Windows capabilities: $_" |
425 | 437 | } |
426 | 438 | } |
427 | 439 |
|
|
435 | 447 | Log " Feature $_ was installed but requires a restart" |
436 | 448 | } |
437 | 449 | } |
438 | | - catch {} |
| 450 | + catch { |
| 451 | + Log " Unable to add Windows capability: $_" |
| 452 | + } |
439 | 453 | } |
440 | 454 | } |
441 | 455 |
|
|
563 | 577 | { |
564 | 578 | MkDir $dest -Force | Out-Null |
565 | 579 | } |
566 | | - Copy-Item ".\initial_preferences" "$dest\" -Force |
| 580 | + Copy-Item "$PSScriptRoot\initial_preferences" "$dest\" -Force |
567 | 581 | if (Test-Path "C:\Users\Public\Desktop\Google Chrome.lnk") { |
568 | 582 | Log "Removing Chrome desktop shortcut" |
569 | 583 | Remove-Item "C:\Users\Public\Desktop\Google Chrome.lnk" -Force |
|
0 commit comments