function Run_Scan {
    param (
        [string]$filePath
    )

    $results = Start-MpScan -ScanType Custom -ScanPath $filePath -ErrorAction SilentlyContinue

    if ($results) {
        Write-Output "Threats found: $results"
        try {
            Remove-Item -Path $filePath -Force -ErrorAction Stop
            Write-Output "File removed: $filePath"
        }
        catch {
            Write-Output "Failed to remove file: $filePath. Error: $_"
        }
    }
    else {
        Write-Output "No threats found"
    }

    Write-Host "Scan completed"
}
