-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWorkingLate.ps1
137 lines (99 loc) · 4.21 KB
/
WorkingLate.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<#
.SYNOPSIS
PowerShell version "smack_my_bitch_up.py"
.NOTES
Created on: 11/25/2015 12:28 PM
Created by: Kevin Elwell
Filename: WorkingLate.ps1
FileVersion: 1.2
.DESCRIPTION
PowerShell version "smack_my_bitch_up.py" script. Generates random person, asskissing and reasons to be sent via SMS.
Currently the script outputs to the console.
.LINK
Credit: Alex Jumašev @ www.jitbit.com
Reference: https://www.jitbit.com/alexblog/249-now-thats-what-i-call-a-hacker/
.TODO
Add SMS functionality via API (looking into free SMS API')
Add logic to detect if I am logged into server/workstation xxxxxxx by getting the user context explorer.exe is running under.
If it is my user context, the time is after 6:00pm EST and it is NOT a Saturday or Sunday, send the SMS message.
Logging function is available for use.
#>
#region Application Variables
#----------------------------------------------
#----------- Begin Variables ------------------
#----------------------------------------------
# Define some variables
$AppName ="WorkingLate"
$logPath = "$env:windir\Logs\$AppName"
$logfile = "$AppName.log"
$today = Get-Date
$dayofweek = $today.DayOfWeek.ToString()
$hourofday = $today.Hour.ToString()
#----------------------------------------------
#------------- End Variables ------------------
#----------------------------------------------
#endregion Application Variables
#region Application Functions
#----------------------------------------------
#------------- Begin Functions ----------------
#----------------------------------------------
# Logging function
Function Log([string]$logmessage)
{
if (!(test-path $logPath))
{
New-Item $LogPath -type directory
"[" + (Get-Date).ToString()+ "]" + " - " + $logmessage | out-file -Filepath $LogPath\$logfile -append
}else{
"[" + (Get-Date).ToString()+ "]" + " - " + $logmessage | out-file -Filepath $LogPath\$logfile -append
}
}
#----------------------------------------------
#--------------- End Functions ----------------
#----------------------------------------------
#region
#------------------------------------------------
#-------------- Begin Arrays --------------------
#------------------------------------------------
# Array of names
$personarray = @("mike","Steve","dave","Paul","Phil","Kevin","Sam","Alex","Andrew","my boss","my Director","my co-worker")
# Pull a random name
$person = Get-Random -InputObject $personarray
# Array of ass kissing
$asskissingarray = @("love you!","so sorry.","I will call you when i leave.")
# Pull a random ass kissing statement
$asskissing = Get-Random -InputObject $asskissingarray
# Array of reasons
$reasonarray = @("working on some important code.","my manager volunteered me for something.","got pulled into a meeting.","helping $person. Again!","$person messed up a deployment. I am helping troubleshoot the issue.","$person asked me for some help.")
# Pull a random reason
$reason = Get-Random -InputObject $reasonarray
#------------------------------------------------
#---------------- End Arrays --------------------
#------------------------------------------------
#endregion
#region Validation
#------------------------------------------------
#-------------- Begin Validations ---------------
#------------------------------------------------
# Validate the day is NOT Saturday or Sunday
If($dayofweek -ne "Saturday" -or $dayofweek -ne "Sunday") {
# Validate the hour is greater than or equal to 18 (6:00PM)
If($hourofday -ge "18") {
$ok2send = $true
}
}
# If its not Saturday or Sunday and it is past 6:00PM, send the SMS message
If($ok2send) {
#///////////////////////////////////////////////////////
# This is where you will change the logic to send the SMS
# instead of outputing to the console.
#///////////////////////////////////////////////////////
# Output to console
write-host "Working late, $reason $asskissing"
#///////////////////////////////////////////////////////
#///////////////////////////////////////////////////////
}
#------------------------------------------------
#--------------- End Validations ----------------
#------------------------------------------------
#endregion Validation