Skip to content

Commit 61f7950

Browse files
committed
Merge pull request NARKOZ#46 from chenghuang-mdsol/master
Add powershell script smack_my_bitch_up.ps1
2 parents 47e8900 + 44d5c57 commit 61f7950

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

powershell/smack_my_bitch_up.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+

0 commit comments

Comments
 (0)