Bläddra i källkod

Update 'KBRemover.ps1'

Ethan 3 år sedan
förälder
incheckning
dbee786a4c
1 ändrade filer med 28 tillägg och 23 borttagningar
  1. 28
    23
      KBRemover.ps1

+ 28
- 23
KBRemover.ps1 Visa fil

@@ -1,26 +1,31 @@
1
-# Check if Hotfix KB5020687 is Installed
2
-$hotfix1 = Get-HotFix -Id KB5020687
3
-if ($hotfix1) {
4
-    # Uninstall Hotfix KB5020687
5
-    Uninstall-WindowsUpdate -KBArticleID KB5020687 -Confirm:$false
6
-    $hotfix1installed = $true
7
-}
1
+try {
2
+    # Check if Hotfix KB5020687 is Installed
3
+    $hotfix1 = Get-HotFix -Id KB5020687
4
+    if ($hotfix1) {
5
+        # Uninstall Hotfix KB5020687
6
+        Uninstall-WindowsUpdate -KBArticleID KB5020687 -Confirm:$false
7
+        $hotfix1installed = $true
8
+    }
8 9
 
9
-# Check if Hotfix KB5019959 is Installed
10
-$hotfix2 = Get-HotFix -Id KB5019959
11
-if ($hotfix2) {
12
-    # Uninstall Hotfix KB5019959
13
-    Uninstall-WindowsUpdate -KBArticleID KB5019959 -Confirm:$false
14
-    $hotfix2installed = $true
15
-}
10
+    # Check if Hotfix KB5019959 is Installed
11
+    $hotfix2 = Get-HotFix -Id KB5019959
12
+    if ($hotfix2) {
13
+        # Uninstall Hotfix KB5019959
14
+        Uninstall-WindowsUpdate -KBArticleID KB5019959 -Confirm:$false
15
+        $hotfix2installed = $true
16
+    }
16 17
 
17
-if ($hotfix1installed -or $hotfix2installed) {
18
-    # Create a System Restore Point
19
-    Checkpoint-Computer -Description "Hotfixes Removed"
20
-    # Display a message
21
-    Write-Host "Hotfixes removed."
22
-} else {
23
-    # Display a message
24
-    Write-Host "Hotfixes not detected. No operation was performed."
18
+    if ($hotfix1installed -or $hotfix2installed) {
19
+        # Create a System Restore Point
20
+        Checkpoint-Computer -Description "Hotfixes Removed"
21
+        # Display a message
22
+        Write-Host "Hotfixes removed."
23
+        [console]::beep()
24
+    } else {
25
+        # Display a message
26
+        Write-Host "Hotfixes not detected. No operation was performed."
27
+    }
28
+} catch {
29
+    $errorMessage = $_.Exception.Message
30
+    [System.Windows.Forms.MessageBox]::Show("An error occurred: $errorMessage")
25 31
 }
26
-pause

Powered by TurnKey Linux.