$ErrorActionPreference = 'SilentlyContinue'
Write-Host '1. Удаление MSI, если система ставилась через установщик...'
$roots = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
$apps = Get-ItemProperty $roots |
Where-Object { $_.DisplayName -eq 'Peripheral Sentinel' }
foreach ($app in $apps) {
$productCode = $null
if ($app.PSChildName -match '^\{[0-9A-F-]+\}$') {
$productCode = $app.PSChildName
}
elseif ($app.UninstallString -match '\{[0-9A-F-]+\}') {
$productCode = $Matches[0]
}
if ($productCode) {
Start-Process msiexec.exe `
-ArgumentList "/x $productCode /qn /norestart" `
-Wait
}
}
Write-Host '2. Остановка процессов и службы...'
Get-Process -Name @(
'PeripheralAnalyzer',
'PeripheralSentinel.Service',
'PeripheralSentinel.UpdateHost'
) -ErrorAction SilentlyContinue | Stop-Process -Force
Stop-Service -Name 'PeripheralSentinel' -Force -ErrorAction SilentlyContinue
sc.exe delete PeripheralSentinel | Out-Null
Write-Host '3. Удаление автозапуска и заданий...'
Remove-ItemProperty `
-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' `
-Name 'Peripheral Sentinel' -Force -ErrorAction SilentlyContinue
Remove-ItemProperty `
-Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' `
-Name 'Peripheral Sentinel' -Force -ErrorAction SilentlyContinue
Remove-ItemProperty `
-Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run' `
-Name 'Peripheral Sentinel' -Force -ErrorAction SilentlyContinue
Get-ScheduledTask -ErrorAction SilentlyContinue |
Where-Object {
$_.TaskName -match 'Peripheral.*Sentinel' -or
$_.TaskPath -match 'Peripheral.*Sentinel'
} |
Unregister-ScheduledTask -Confirm:$false
Write-Host '4. Полное удаление файлов, настроек и старых токенов...'
Remove-Item -LiteralPath "$env:ProgramFiles\Peripheral Sentinel" `
-Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath "$env:ProgramData\PeripheralSentinel" `
-Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath "$env:ProgramData\PeripheralSentinelSystem" `
-Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\Peripheral Sentinel.lnk" `
-Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\Peripheral Sentinel.lnk" `
-Force -ErrorAction SilentlyContinue
Write-Host ''
Write-Host 'Очистка завершена. Перезагрузите компьютер.' -ForegroundColor Green