Enable Service

Detection Script

$service = Get-Service -Name "AppIDSvc" -ErrorAction SilentlyContinue
if ($null -eq $service) {
    Write-Output "Not Compliant: Service not found"
    exit 1
}
if ($service.StartType -ne 'Automatic' -or $service.Status -ne 'Running') {
    Write-Output "Not Compliant: Service not set to Automatic or not running"
    exit 1
}
Write-Output "Compliant"
exit 0

Remediation Script

try {
    Set-Service -Name "AppIDSvc" -StartupType Automatic -ErrorAction Stop
} catch {
    Write-Output "Failed to set startup type to Automatic. Error: $_"
    exit 1
}
try {
    Start-Service -Name "AppIDSvc" -ErrorAction Stop
} catch {
    Write-Output "Failed to start AppIDSvc. Error: $_"
    exit 1
}
Write-Output "Remediation completed successfully."
exit 0