Iam creating a pomodoro timer using powershell. testing it with 1 minute interval to display the toast notification.
The below script however does not display the notification after 1 minute.
any advice from the experts will be helpful
function start-pomodoro {
$minutes = 1
$seconds = 60 * $minutes
$sb = {
Start-Sleep -Seconds $args[0]
New-BurntToastNotification -Text ‘Its Time to take a break, relax!!!MOve your body and come back’
Please … When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
( !! Sometimes the preformatted text button hides behind the settings gear symbol. )
I’m not familiar with what a pomodoro timer is - I assume it is something you need to install before you’re able to use it. And since the function New-BurntToastNotification is not part of the default installation of PowerShell as well I’d like to ask you if you have installed all needed dependencies and if there are any error messages when you run this code manually - I mean outside of a job.
I am fairly certain the reason it doesn’t work is because Start-Job doesn’t interact with your user session. You could just have the Powershell script run from a Scheduled task under your user context
it looks like the Typename they leverage has “UI” in it which supports @neemobeer idea. If you’re trying to leverage BurntToast notifications you likely won’t be able to do it from inside of a Job. Scheduled tasks can run as a given user if that’s what you really need like he also suggested.