while(1) { # Loop forever
#
#CHROME
$wshell = New-Object -ComObject wscript.shell
if($wshell.AppActivate(‘Chrome’)) { # Switch to Chrome
Sleep 1 # Wait for Chrome to “activate”
$wshell.SendKeys(‘{F5}’) # Send F5 (Refresh)
Sleep 1
$wshell.SendKeys(‘^{TAB}’) #Go to next tab
Sleep 1
$wshell.SendKeys(‘{F5}’) # Send F5 (Refresh)
Sleep 1
$wshell.SendKeys(‘^{TAB}’) #Go to next tab
Write-Host (“{0} – Refresh of Chrome tabs done, wait 10 mins” -f $(get-date)) -ForegroundColor Green
sleep -Seconds 599 # Wait 10 minutes
} else { break; } # Chrome not open, exit the loop
#
#
#TEAMS
$teamsMainWindowTitle = Get-Process -name “ms-teams” | Where-Object { $_.MainWindowTitle } | Select-Object MainWindowTitle
try {
Get-Process -Name ‘ms-teams’ -ErrorAction stop | Out-Null
Write-Host (“{0} – Microsoft Teams is running…” -f $(get-date)) -ForegroundColor Green
$wshell = New-Object -ComObject wscript.shell
$wshell.AppActivate(“Activity | “) # Switch to Teams
$wshell.sendkeys(“{NUMLOCK}{NUMLOCK}”)
Write-Host (“{0} – Pressed NUMLOCK twice and waiting for 10 seconds” -f $(get-date)) -ForegroundColor Green
Start-Sleep -Seconds 10 #60
}
catch {
Write-Warning ("{0} - Microsoft Teams is not running, sleeping for 15 seconds..." -f $(get-date))
Start-Sleep -Seconds 15
}
}