Skip to content

Commit

Permalink
Update Uninstall_Sysmon64.ps1 (#27)
Browse files Browse the repository at this point in the history
Check if Sysmon is installed, run the uninstall command with elevated privileges, and handle potential errors. 
Remove the Sysmon executable if the uninstallation is successful.
  • Loading branch information
dkorzhevin authored Nov 20, 2023
1 parent 4fd3eb7 commit fb4058e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions Chapter 2 Files/SCCM Deployment/Uninstall_Sysmon64.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## Sysinternals Sysmon64.exe Uninstaller
# Perform automated uninstall
& C:\Windows\Sysmon64.exe -u
# House keep remaining file
Remove-Item C:\Windows\Sysmon64.exe
## Sysinternals Sysmon64.exe Uninstaller
# Check if Sysmon is installed
if (Test-Path "C:\Windows\Sysmon64.exe") {
try {
# Perform automated uninstall with elevated privileges
Start-Process "C:\Windows\Sysmon64.exe" -ArgumentList "-u" -Verb RunAs -Wait

# Housekeep remaining file
Remove-Item "C:\Windows\Sysmon64.exe" -Force
Write-Output "Sysmon uninstalled and removed successfully."
} catch {
Write-Error "Error occurred during Sysmon uninstallation: $_"
}
} else {
Write-Warning "Sysmon is not installed."
}

0 comments on commit fb4058e

Please sign in to comment.