tests/Test-Admin.ps1

# Quick admin test for OfficeScrubC2R
# Run this with: Start-Process pwsh -Verb RunAs -ArgumentList "-NoProfile -File Test-Admin.ps1"

Write-Host "`n=== Admin Test ===" -ForegroundColor Cyan

# Check if running as admin
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
    Write-Host "ERROR: Not running as admin!" -ForegroundColor Red
    exit 1
}

Write-Host "Running as Administrator: YES" -ForegroundColor Green

# Import local module
Set-Location $PSScriptRoot
Import-Module .\OfficeScrubC2R.psd1 -Force

# Test with -DetectOnly and -Confirm:$false
Write-Host "`nTesting Invoke-OfficeScrubC2R -DetectOnly..." -ForegroundColor Yellow
try {
    Invoke-OfficeScrubC2R -DetectOnly -Confirm:$false -ErrorAction Stop
    Write-Host "`nSUCCESS: No path binding errors!" -ForegroundColor Green
}
catch {
    Write-Host "`nFAILED: $_" -ForegroundColor Red
    Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
    exit 1
}

Write-Host "`nAll tests passed!" -ForegroundColor Green
Read-Host "Press Enter to exit"