#Requires -RunAsAdministrator
<#
.SYNOPSIS
    Re-runs GuruScan scanners in clean mode against a previous scan's log folder.
.DESCRIPTION
    Reads the results.json from a prior scan run, then re-launches each scanner
    that completed (or any subset via -Scanners) using clean_args to remove
    detected threats. Writes remediation-results.json to the same log folder.
.PARAMETER LogRoot
    Path to the scan results folder produced by Invoke-GuruScan.ps1.
    This folder must contain a results.json file.
.PARAMETER Scanners
    Run only the named scanners. Names must match the "name" field in
    scanners.json exactly. If omitted, all scanners that previously ran
    successfully are re-run.
.EXAMPLE
    .\Invoke-Remediation.ps1 -LogRoot "C:\ScanLogs\DESKTOP-20260523-143000"
    .\Invoke-Remediation.ps1 -LogRoot "C:\ScanLogs\DESKTOP-20260523-143000" -Scanners AdwCleaner,MSERT
#>
[CmdletBinding()]
param(
    [Parameter(Mandatory = $true)]
    [string]$LogRoot,

    [string[]]$Scanners
)

$moduleManifest = Join-Path $PSScriptRoot 'GuruScan.psd1'
if (-not (Test-Path $moduleManifest)) {
    Write-Host "[ERROR] GuruScan module not found: $moduleManifest" -ForegroundColor Red
    exit 1
}

Import-Module $moduleManifest -Force
Invoke-Remediation @PSBoundParameters
