_original/Desinstalar-WorkloadManager.ps1

# ============================================================
# Desinstalar-WorkloadManager.ps1
# Autor: Dante / SafeAutentic
#
# Revierte todos los cambios del WorkloadManager
# Ejecutar como Administrador
# ============================================================

if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
    Write-Host "ERROR: Ejecuta este script como Administrador." -ForegroundColor Red
    exit 1
}

# 1. Matar proceso activo
Get-Process powershell -ErrorAction SilentlyContinue | Where-Object {
    $_.MainModule.FileName -match "powershell" -and $_.Id -ne $PID
} | Stop-Process -Force -ErrorAction SilentlyContinue

# 2. Eliminar entrada de inicio automatico
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "WorkloadManager" -ErrorAction SilentlyContinue
Write-Host "Inicio automatico eliminado" -ForegroundColor Cyan

# 3. Eliminar archivos
Remove-Item -Path "$env:ProgramData\WorkloadManager" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Archivos eliminados" -ForegroundColor Cyan

# 4. Revertir Recall (opcional - comentar si no quieres reactivar Recall)
$regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsAI"
Remove-ItemProperty -Path $regPath -Name "DisableAIDataAnalysis" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path $regPath -Name "DisableRecall"         -ErrorAction SilentlyContinue
Remove-ItemProperty -Path $regPath -Name "AllowRecallEnablement" -ErrorAction SilentlyContinue
Write-Host "Politicas de Recall revertidas" -ForegroundColor Cyan

Write-Host ""
Write-Host "WorkloadManager desinstalado correctamente." -ForegroundColor Green