none
What are all the values of [DayofTheWeek]? RRS feed

  • Question

  • Hi Guys,

    I'm currently experimenting with running jobs under a gMSA account (which works splendid thanks to a nice blog you can find on technet) and now I want to retrieve all jobs running with all the info. I noticed something when getting the numbers:

    $counter= 1
    $GetTaskNumber = 0
    $AllTasks = Get-ScheduledTask * -TaskPath "\Scripts\*" | %{$_ | Add-Member -Name "Number" -Value $counter -Type NoteProperty -PassThru; $counter++ } | Select-Object -Property *
    
    Write-host "All Current tasks:"
    Write-Host "--------------------" -ForegroundColor Green
    $AllTasks | Select-Object Number,TaskName,Taskpath,Triggers | sort-object Number | ft -AutoSize
    write-host "--------------------" -ForegroundColor Green
    
    Write-Host "Which tasks would you like to change?" -ForegroundColor Yellow
    
    Do {$GetTaskNumber = Read-host "Select a task number between 0 and $($AllTasks.Count). If selected 0 the script will end"} while ( (0..$($AllTasks.Count)) -notcontains $GetTaskNumber)
    
    if($GetTaskNumber -eq 0){throw "Script ended by user!"}
    else{ $test = $AllTasks | ?{$_.Number -eq $GetTaskNumber}}
    $test.triggers | fl
    
    

    (the task in the above script was to select a task and then after change some triggers, but I still need to display them.)

    This is the output:

    powershell output

    Notice the "DaysOfWeek" = 46 --> (which you might think, okay this could be thursday and saturday, hence the 4 and 6

    But when you look in the task scheduler:

    Task Scheduler picture

    The Question:

    What are all the values of the [DaysoftheWeek]? I can't seem to find anything online (aka google / technet)

    Second Question: Eventually I want to Get a list of all jobs, with their triggers and sent it as an email with Send-MailMessage, this is quite hard as you can see in the above output. It only says numbers or "MSFT_TASKREPITIONPATTERN" or "PODTOHOMOS" (whatever that means o.o) How would I do this for best practice? Create a custom object and then "translate" everything or is there something I do not know about?


    If you find an answer has helped you please use the answer button and/or use that thumbs up! Julio Sanchez-Tirado http://scriptomato.com co-founder | CEO | Pitcher


    Wednesday, July 26, 2017 10:31 AM

Answers