<# .SYNOPSIS Elevated read-out of the Beletage-DNS-Location-Suffix task (triggers, principal, last run) to C:\ProgramData\Beletage\verify.txt. The task runs as SYSTEM with a restrictive security descriptor, so it is not queryable from a non-elevated shell. Run elevated: Start-Process powershell -Verb RunAs -ArgumentList '-NoProfile','-ExecutionPolicy','Bypass','-File','\verify-dns-location-task.ps1' #> $ErrorActionPreference = 'Stop' $out = 'C:\ProgramData\Beletage\verify.txt' $name = 'Beletage-DNS-Location-Suffix' $lines = @() try { $t = Get-ScheduledTask -TaskName $name $lines += "FOUND $($t.TaskName) State=$($t.State)" $lines += "Principal $($t.Principal.UserId) RunLevel=$($t.Principal.RunLevel) LogonType=$($t.Principal.LogonType)" $lines += "Triggers $($t.Triggers.Count)" foreach ($tr in $t.Triggers) { $cn = $tr.CimClass.CimClassName $tag = if ($tr.Subscription) { ' (event: NetworkProfile connected / EventID 10000)' } else { '' } $lines += " - $cn$tag" } $info = Get-ScheduledTaskInfo -TaskName $name $lines += "LastRun $($info.LastRunTime) LastResult=0x$('{0:X}' -f $info.LastTaskResult)" $lines += "NextRun $($info.NextRunTime)" } catch { $lines += "ERROR $($_.Exception.Message)" } $lines | Set-Content -Path $out -Encoding UTF8