File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ $DAYOFWEEK = (Get-Date ).DayOfWeek.value__;
2
+
3
+ # Skip on weekends
4
+ if ($DAYOFWEEK -eq 6 -or $DAYOFWEEK -eq 7 ) {
5
+ return
6
+ }
7
+
8
+ # Exit early if no sessions with my username are found
9
+ if ((QWINSTA $env: USERNAME | measure).Count -gt 0 ){
10
+ return
11
+ }
12
+
13
+ # Phone numbers
14
+ $MY_NUMBER = ' +xxx'
15
+ $HER_NUMBER = ' +xxx'
16
+
17
+ $TWILIO_ACCOUNT_SID = ' xxx'
18
+ $TWILIO_AUTH_TOKEN = ' xxx'
19
+
20
+ $REASONS =
21
+ ' Working hard' ,
22
+ ' Gotta ship this feature' ,
23
+ ' Someone fucked the system again'
24
+
25
+ $RAND = Get-Random - Maximum $REASONS.Count
26
+
27
+ $MSG = " Late at work. $REASONS [$RAND ]"
28
+
29
+
30
+ $BASE64AUTHINFO = [Convert ]::ToBase64String([Text.Encoding ]::ASCII.GetBytes((" {0}:{1}" -f $TWILIO_ACCOUNT_SID , $TWILIO_AUTH_TOKEN )))
31
+
32
+ # Send a text messag and Log errors
33
+ try {
34
+ Invoke-RestMethod - Method Post - Headers @ {Authorization = (" Basic {0}" -f $BASE64AUTHINFO )} " https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID /Messages" - Body " From=$MY_NUMBER &To=$HER_NUMBER &Body=$MSG " > $null
35
+ }
36
+ catch {
37
+ Write-Host " Failed to send SMS: $_ "
38
+ }
39
+
You can’t perform that action at this time.
0 commit comments