From b84ae302e1c71754925a26aeed62483e512de84f Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Wed, 8 Jan 2025 14:00:55 +0300 Subject: [PATCH] Improved error handling --- .github/workflows/Sophia.yml | 3 +-- src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 | 11 +---------- .../Module/Sophia.psm1 | 13 ++----------- src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 | 11 +---------- .../Module/Sophia.psm1 | 11 +---------- .../Module/Sophia.psm1 | 13 ++----------- 6 files changed, 8 insertions(+), 54 deletions(-) diff --git a/.github/workflows/Sophia.yml b/.github/workflows/Sophia.yml index d95721f8..654c3812 100644 --- a/.github/workflows/Sophia.yml +++ b/.github/workflows/Sophia.yml @@ -105,8 +105,7 @@ jobs: echo "RELEASE_NAME=$ReleaseName" >> $env:GITHUB_ENV - name: Uploading - # https://github.com/softprops/action-gh-release/issues/556#issuecomment-2556947371 - uses: softprops/action-gh-release@v2.1.0 + uses: softprops/action-gh-release@master with: name: ${{ steps.read_release.outputs.RELEASE_NAME }} token: ${{ github.token }} diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index bf7b5ddf..746c97f3 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -11388,20 +11388,11 @@ function UninstallUWPApps # The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually $Packages = @( - # Spotify - "SpotifyAB.SpotifyMusic", - - # Disney+ - "Disney.37853FC22B2CE", - # Outlook "Microsoft.OutlookForWindows", # Microsoft Teams - "MSTeams", - - # Microsoft Copilot - "Microsoft.Windows.Ai.CoPilot.Provider" + "MSTeams" ) foreach ($Package in $Packages) { diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 index 4da3e481..24641078 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 @@ -581,7 +581,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); { (Get-MpPreference -ErrorAction Stop).EnableControlledFolderAccess } - catch [Microsoft.Management.Infrastructure.CimException] + catch [System.Management.Automation.RemoteException] { Write-Information -MessageData "" -InformationAction Continue Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") @@ -11418,20 +11418,11 @@ function UninstallUWPApps # The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually $Packages = @( - # Spotify - "SpotifyAB.SpotifyMusic", - - # Disney+ - "Disney.37853FC22B2CE", - # Outlook "Microsoft.OutlookForWindows", # Microsoft Teams - "MSTeams", - - # Microsoft Copilot - "Microsoft.Windows.Ai.CoPilot.Provider" + "MSTeams" ) foreach ($Package in $Packages) { diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index a48367ba..7fa515b8 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -10584,20 +10584,11 @@ function UninstallUWPApps # The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually $Packages = @( - # Spotify - "SpotifyAB.SpotifyMusic", - - # Disney+ - "Disney.37853FC22B2CE", - # Outlook "Microsoft.OutlookForWindows", # Microsoft Teams - "MSTeams", - - # Microsoft Copilot - "Microsoft.Windows.Ai.CoPilot.Provider" + "MSTeams" ) foreach ($Package in $Packages) { diff --git a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 index 15c87461..221ea80a 100644 --- a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 @@ -10057,20 +10057,11 @@ function UninstallUWPApps # The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually $Packages = @( - # Spotify - "SpotifyAB.SpotifyMusic", - - # Disney+ - "Disney.37853FC22B2CE", - # Outlook "Microsoft.OutlookForWindows", # Microsoft Teams - "MSTeams", - - # Microsoft Copilot - "Microsoft.Windows.Ai.CoPilot.Provider" + "MSTeams" ) foreach ($Package in $Packages) { diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 index a706e3ef..8113c4d1 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 @@ -568,7 +568,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); { (Get-MpPreference -ErrorAction Stop).EnableControlledFolderAccess } - catch [Microsoft.Management.Infrastructure.CimException] + catch [System.Management.Automation.RemoteException] { Write-Information -MessageData "" -InformationAction Continue Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") @@ -10614,20 +10614,11 @@ function UninstallUWPApps # The -PackageTypeFilter Bundle doesn't contain these packages, and we need to add manually $Packages = @( - # Spotify - "SpotifyAB.SpotifyMusic", - - # Disney+ - "Disney.37853FC22B2CE", - # Outlook "Microsoft.OutlookForWindows", # Microsoft Teams - "MSTeams", - - # Microsoft Copilot - "Microsoft.Windows.Ai.CoPilot.Provider" + "MSTeams" ) foreach ($Package in $Packages) {