A user encountered an issue when running a script for pulling in a scheduled tasks trigger info. The output created an index that was empty and when clicked it showed a blank page. With the help of @member, they were able to create a script that would output details from the Trigger including StartBoundary, DaysOfWeek, WeeksInterval, DaysInterval, and NextRunTime. It was suggested that specific values may have been an issue with the output, but it was not concluded.
Read the entire ‘Fixing an Issue with Outputting Scheduled Tasks Trigger Info’ thread below:
Running into an issue w/ a script that is pulling in a scheduled tasks trigger info. If i run it locally it works ok and pushing in in Edge DX does not appear to throw any errors. It creates the index but empty data and when you click on the index its a blank page.
“`Write-Output("### SIP DATA BEGINS ###")
Get-ScheduledTask -TaskName "HP BIOS Updates" | Select-Object -ExpandProperty Triggers | ConvertTo-Json
Write-Output("### SIP DATA ENDS ###") “`Maybe there are invalid characters in the output that JSON is not happy with? And I assume you’ve left the line that sets system encoding in the script?
Sidenote, personally I like to define the return outside the ‘SIP DATA’ part, just to make sure I never mess it up. Something like this:
“`$return = Get-ScheduledTask -TaskName "HP BIOS Updates" | Select-Object -ExpandProperty Triggers | ConvertTo-Json
Write-Output("### SIP DATA BEGINS ###")
$return
Write-Output("### SIP DATA ENDS ###") “`
But that is just me being paranoid as well 😉i do have the encoding part in there yes but good point to remember. i’ll try your code quick to test
ok your version it didnt like BUT using my original ran but eventually gave this error: Some items failed to upload. RunScriptFileAsSystem error during POST Json output: {"items_sent":1,"created":0,"failed":1,"uid":"bef1a15c87e84045af09e4f4143f6da2"}Not sure why $return did not work. I usually actually do ‘Write-Output -InputObject $return’ but again that is being a tad OCD. Either way, that is not the issue you are trying to solve.
I ran your code for the Adobe Update Task, there is a lot of nested data in that Trigger (disclaimer: I don’t know if your HP BIOS Updates" is the same type of trigger). Maybe get that object with the Trigger without converting it to details, then create a hashtable with the specific data you would like to see recorded (a lot in my trigger data is useless) and output that table while converting it to JSON.
thanks for the troubleshooting here! do you have a tweaked version of the code i can mess with by chance?
If the info is not sensitive, send me the output of your script in a DM and what properties you would like to see recorded, I can take a shot.
awesome thanks for the help!
Always wait with thx until yer sure I’ve not blown up yer computer 😉
haha thats fair
for anyone interested, this is the working script w/ the help of @member!“`[pscustomobject]$objTask = Get-ScheduledTask -TaskName "TaskName"
Create hashtable for output, use Get-ScheduledTaskInfo to get next run time
[hashtable]$hshReturn = @{
‘StartBoundary’ = $objTask.Triggers.StartBoundary
‘DaysOfWeek’= $objTask.Triggers.DaysOfWeek
‘WeeksInterval’ = $objTask.Triggers.WeeksInterval
‘DaysInterval’ = $objTask.Triggers.DaysInterval
‘NextRunTime’ = ($objTask | Get-ScheduledTaskInfo).NextRunTime.ToString()
}
Write dem deets
Write-Output("### SIP DATA BEGINS ###")
Write-Output -InputObject $hshReturn | ConvertTo-Json
Write-Output("### SIP DATA ENDS ###")“`so that script works nicely…..however the index and report built off of it is a bit strange w/ the columns (i added enabled to the above script to show that as well) . notice the up/down buttons on some columns and enabled does not have a filter box at all
I don’t think that is related to your script though, may one of the Edge experts can explain why it works this way.
That’s what I was thinking…. Something with those specific values maybe. Not a huge deal but just odd so thought I’d mention
Continue reading and comment on the thread ‘Fixing an Issue with Outputting Scheduled Tasks Trigger Info’. Not a member? Join Here!
Categories: All Archives, ControlUp for Desktops, ControlUp Scripts & Triggers