End Your Work Day With A Script

Trying to give myself things to learn with Powershell. I thought, “what’s a good way of forcing myself to disconnect from Teams/Slack as that shows me as available to the company I work for”. We’ll I came up with a little script that finds the time and then starts/stop services based -gt (greater than) times.

##################################################################
#   Scripts purpose is to stop you from working after 5:00 PM &  #
#   start service when you need to work                          #
##################################################################

#Get time
$OOP = Get-Date

#Strategy

if ($OOP -gt '5:00 PM') {
    Get-Process Teams, slack | Stop-Process -Force
}
elseif ($OOP -gt '8:00 AM') {
    Get-Process Teams, slack | Start-Process -Force
} 

A sample of the script is above ^. If you would like to automate this daily you would just have to simply open Task Scheduler and set up the script to run weekly with the preferred week days. Remember to set the application to powershell.exe -File “Path to script” in the variables of the task schedule. Two will be needed if you want to start and stop the day.

Leave a Reply

Your email address will not be published. Required fields are marked *