Stworzyłem skrypt który wypisuje mi moje Zadania w Harmonogramie.
Lecz problem mam taki , że w wyniku w Wartości LastResult otrzymuje kod informacji np: 267011. Chciałbym , żeby w tym polu pojawiał się określony string zamiast tych wartości
Podrzućcie rozwiązanie bo zbyt długo już siedzę nad taką rozkminą.
$test = Get-ScheduledTask|
ForEach-Object { [pscustomobject]@{
Name = $_.TaskName
Path = $_.TaskPath
LastResult = $(($_ | Get-ScheduledTaskInfo).LastTaskResult)
NextRun = $(($_ | Get-ScheduledTaskInfo).NextRunTime)
Status = $_.State
Command = $_.Actions.execute
Arguments = $_.Actions.Arguments }
}
$test
Przykładowy output :
Name : Recovery-Check
Path : \Microsoft\Windows\Workplace Join\
LastResult : 267011
NextRun :
Status : Disabled
Command : %SystemRoot%\System32\dsregcmd.exe
Arguments : /checkrecovery
Chciałbym mieć :
Name : Recovery-Check
Path : \Microsoft\Windows\Workplace Join\
LastResult : Task has not yet run.
NextRun :
Status : Disabled
Command : %SystemRoot%\System32\dsregcmd.exe
Arguments : /checkrecovery
oto lista innych kodów :
0 = "The operation completed successfully."
1 = "Incorrect function called or unknown function called. 2 File not found."
10 = "The environment is incorrect."
267008 = "Task is ready to run at its next scheduled time."
267009 = "Task is currently running."
267010 = "The task will not run at the scheduled times because it has been disabled."
267011 = "Task has not yet run."
267012 = "There are no more runs scheduled for this task"
267013 = "One or more of the properties that are needed to run this task on a schedule have not been set."
267014 = "The last run of the task was terminated by the user."
267015 = "Either the task has no triggers or the existing triggers are disabled or not set."
2147750671 = "Credentials became corrupted."
2147750687 = "An instance of this task is already running."
2147943645 = "The service is not available (is Run only when an user is logged on checked?)."
3221225786 = "The application terminated as a result of a CTRL+C."
3228369022 = "Unknown software exception."